@starlein/paperclip-plugin-company-wizard 0.4.11 → 0.4.13

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/worker.js CHANGED
@@ -9282,7 +9282,7 @@ import { join } from "node:path";
9282
9282
  var DEFAULT_CEO_ADAPTER_TYPE = "codex_local";
9283
9283
  var DEFAULT_CEO_MODEL = "gpt-5.5";
9284
9284
  var DEFAULT_CEO_THINKING_LEVEL = "high";
9285
- var DEFAULT_WORKER_THINKING_LEVEL = "medium";
9285
+ var DEFAULT_WORKER_THINKING_LEVEL = "auto";
9286
9286
  var DEFAULT_CEO_MAX_CONCURRENT_RUNS = 1;
9287
9287
  var DEFAULT_CEO_HEARTBEAT_INTERVAL_SEC = 3600;
9288
9288
  var DEFAULT_CLAUDE_CEO_MODEL = "claude-opus-4-6";
@@ -9306,7 +9306,7 @@ function buildAdapterConfig({
9306
9306
  const defaultModel = adapterType === "claude_local" ? DEFAULT_CLAUDE_CEO_MODEL : DEFAULT_CEO_MODEL;
9307
9307
  const model = userModel || overrideModel || defaultModel;
9308
9308
  const userThinking = inheritUserThinking ? asTrimmedString(userCeoAdapter.thinkingLevel) || asTrimmedString(userCeoAdapter.modelReasoningEffort) || asTrimmedString(userCeoAdapter.reasoningEffort) : "";
9309
- const thinkingLevel = userThinking || asTrimmedString(roleAdapterOverrides.thinkingLevel) || asTrimmedString(roleAdapterOverrides.modelReasoningEffort) || asTrimmedString(roleAdapterOverrides.reasoningEffort) || defaultThinkingLevel;
9309
+ const thinkingLevel = userThinking || asTrimmedString(roleAdapterOverrides.thinkingLevel) || asTrimmedString(roleAdapterOverrides.modelReasoningEffort) || asTrimmedString(roleAdapterOverrides.reasoningEffort) || asTrimmedString(roleAdapterOverrides.effort) || defaultThinkingLevel;
9310
9310
  const adapterConfig = {
9311
9311
  ...roleAdapterOverrides,
9312
9312
  cwd: userCwd || companyDir,
@@ -9314,6 +9314,10 @@ function buildAdapterConfig({
9314
9314
  };
9315
9315
  delete adapterConfig.promptTemplate;
9316
9316
  delete adapterConfig.bootstrapPromptTemplate;
9317
+ delete adapterConfig.thinkingLevel;
9318
+ delete adapterConfig.modelReasoningEffort;
9319
+ delete adapterConfig.reasoningEffort;
9320
+ delete adapterConfig.effort;
9317
9321
  if (adapterType === "codex_local") {
9318
9322
  adapterConfig.modelReasoningEffort = thinkingLevel;
9319
9323
  adapterConfig.thinkingLevel = thinkingLevel;
@@ -9526,6 +9530,14 @@ async function assembleCompany({
9526
9530
  const initialRoutines = Array.isArray(presetRoutines) ? presetRoutines.map((routine) => ({ ...routine, source: routine.source || "preset" })) : [];
9527
9531
  const explicitBootstrapLabels = Array.isArray(presetLabels) ? [...presetLabels] : [];
9528
9532
  const roleAdapterOverrides = /* @__PURE__ */ new Map();
9533
+ for (const role of allRoles) {
9534
+ const roleMeta = roleMetaByName.get(role) || {};
9535
+ const adapter = roleMeta && typeof roleMeta.adapter === "object" ? roleMeta.adapter : {};
9536
+ const thinkingLevel = typeof adapter.thinkingLevel === "string" && adapter.thinkingLevel.trim() || typeof adapter.modelReasoningEffort === "string" && adapter.modelReasoningEffort.trim() || typeof adapter.reasoningEffort === "string" && adapter.reasoningEffort.trim() || typeof adapter.effort === "string" && adapter.effort.trim() || "";
9537
+ if (thinkingLevel) {
9538
+ roleAdapterOverrides.set(role, { thinkingLevel });
9539
+ }
9540
+ }
9529
9541
  const docRoleMap = /* @__PURE__ */ new Map();
9530
9542
  const addDocRoles = (docName, roles) => {
9531
9543
  const set = docRoleMap.get(docName) ?? /* @__PURE__ */ new Set();
@@ -10563,6 +10575,14 @@ var PaperclipClient = class {
10563
10575
  body: JSON.stringify({ name, description: description || null })
10564
10576
  });
10565
10577
  }
10578
+ /**
10579
+ * List all companies the connected identity can see.
10580
+ * Returns the raw array from `GET /api/companies`.
10581
+ */
10582
+ async listCompanies() {
10583
+ const result = await this._fetch("/api/companies", { method: "GET" });
10584
+ return Array.isArray(result) ? result : result?.companies ?? [];
10585
+ }
10566
10586
  async updateCompany(companyId, updates) {
10567
10587
  return this._fetch(`/api/companies/${companyId}`, {
10568
10588
  method: "PATCH",
@@ -11003,7 +11023,7 @@ var __dirname = path2.dirname(fileURLToPath2(import.meta.url));
11003
11023
  var DEFAULT_TEMPLATES_REPO_URL = "https://github.com/starlein/paperclip-plugin-company-wizard/tree/main/templates";
11004
11024
  var BUNDLED_TEMPLATES_DIR = path2.resolve(__dirname, "..", "templates");
11005
11025
  var PLUGIN_PACKAGE_NAME = "@starlein/paperclip-plugin-company-wizard";
11006
- var CURRENT_PLUGIN_VERSION = "0.4.11";
11026
+ var CURRENT_PLUGIN_VERSION = "0.4.13";
11007
11027
  var NPM_LATEST_URL = "https://registry.npmjs.org/@starlein%2Fpaperclip-plugin-company-wizard/latest";
11008
11028
  function copyDirSync(src, dest) {
11009
11029
  fs2.mkdirSync(dest, { recursive: true });
@@ -11182,16 +11202,42 @@ function loadTemplates(templatesDir) {
11182
11202
  loadErrors: [...presetLoad.errors, ...moduleLoad.errors, ...roleLoad.errors]
11183
11203
  };
11184
11204
  }
11205
+ function resolvePaperclipCredentials(cfg) {
11206
+ return {
11207
+ url: cfg.paperclipUrl || process.env.PAPERCLIP_PUBLIC_URL || "http://localhost:3100",
11208
+ email: cfg.paperclipEmail || "",
11209
+ password: cfg.paperclipPassword || ""
11210
+ };
11211
+ }
11212
+ var sharedAuthCache = null;
11213
+ var SHARED_AUTH_TTL_MS = 5 * 60 * 1e3;
11214
+ async function connectSharedClient(cfg) {
11215
+ const { url, email, password } = resolvePaperclipCredentials(cfg);
11216
+ const key = `${url}|${email}`;
11217
+ const client = new PaperclipClient(url, { email, password });
11218
+ if (sharedAuthCache && sharedAuthCache.key === key && Date.now() - sharedAuthCache.ts < SHARED_AUTH_TTL_MS) {
11219
+ client.sessionCookie = sharedAuthCache.sessionCookie;
11220
+ client.boardUserId = sharedAuthCache.boardUserId;
11221
+ client.boardUserName = sharedAuthCache.boardUserName;
11222
+ client.boardUserEmail = sharedAuthCache.boardUserEmail;
11223
+ if (await client.ping()) {
11224
+ return client;
11225
+ }
11226
+ }
11227
+ await client.connect();
11228
+ sharedAuthCache = {
11229
+ key,
11230
+ ts: Date.now(),
11231
+ sessionCookie: client.sessionCookie,
11232
+ boardUserId: client.boardUserId,
11233
+ boardUserName: client.boardUserName,
11234
+ boardUserEmail: client.boardUserEmail
11235
+ };
11236
+ return client;
11237
+ }
11185
11238
  async function resolveEnableIsolatedWorkspacesFromInstance(cfg, log) {
11186
- const paperclipUrl = cfg.paperclipUrl || process.env.PAPERCLIP_PUBLIC_URL || "http://localhost:3100";
11187
- const paperclipEmail = cfg.paperclipEmail || "";
11188
- const paperclipPassword = cfg.paperclipPassword || "";
11189
- const instanceClient = new PaperclipClient(paperclipUrl, {
11190
- email: paperclipEmail,
11191
- password: paperclipPassword
11192
- });
11193
11239
  try {
11194
- await instanceClient.connect();
11240
+ const instanceClient = await connectSharedClient(cfg);
11195
11241
  const experimentalSettings = await instanceClient.getInstanceExperimentalSettings();
11196
11242
  return experimentalSettings?.enableIsolatedWorkspaces === true;
11197
11243
  } catch (err) {
@@ -11720,9 +11766,6 @@ var plugin = definePlugin({
11720
11766
  return { error: "existingCompanyId is required for preview." };
11721
11767
  }
11722
11768
  const cfg = await ctx.config.get() ?? {};
11723
- const paperclipUrl = cfg.paperclipUrl || process.env.PAPERCLIP_PUBLIC_URL || "http://localhost:3100";
11724
- const paperclipEmail = cfg.paperclipEmail || "";
11725
- const paperclipPassword = cfg.paperclipPassword || "";
11726
11769
  const companyName = typeof params.companyName === "string" && params.companyName.trim() ? params.companyName.trim() : "Preview";
11727
11770
  const templatesDir = await ensureTemplatesDir(cfg);
11728
11771
  tmpDir = path2.join(os.tmpdir(), `company-wizard-preview-update-${Date.now()}`);
@@ -11765,11 +11808,7 @@ var plugin = definePlugin({
11765
11808
  const teamRoles = allRoles.filter((r) => r && r !== "ceo");
11766
11809
  let plannedFiles = 0;
11767
11810
  countFiles2(assembleResult.companyDir);
11768
- const client = new PaperclipClient(paperclipUrl, {
11769
- email: paperclipEmail,
11770
- password: paperclipPassword
11771
- });
11772
- await client.connect();
11811
+ const client = await connectSharedClient(cfg);
11773
11812
  const company = await client.getCompany(existingCompanyId);
11774
11813
  const existingAgents = await client.listAgents(existingCompanyId);
11775
11814
  const existingRoutines = await client.listRoutines(existingCompanyId);
@@ -11902,19 +11941,29 @@ var plugin = definePlugin({
11902
11941
  }
11903
11942
  });
11904
11943
  ctx.actions.register("check-auth", async () => {
11905
- const cfg = await ctx.config.get() ?? {};
11906
- const paperclipUrl = cfg.paperclipUrl || process.env.PAPERCLIP_PUBLIC_URL || "http://localhost:3100";
11907
11944
  try {
11908
- const client = new PaperclipClient(paperclipUrl, {
11909
- email: cfg.paperclipEmail || "",
11910
- password: cfg.paperclipPassword || ""
11911
- });
11912
- await client.connect();
11945
+ const cfg = await ctx.config.get() ?? {};
11946
+ await connectSharedClient(cfg);
11913
11947
  return { ok: true };
11914
11948
  } catch (err) {
11915
11949
  return { ok: false, error: err instanceof Error ? err.message : String(err) };
11916
11950
  }
11917
11951
  });
11952
+ ctx.actions.register("list-companies", async () => {
11953
+ try {
11954
+ const cfg = await ctx.config.get() ?? {};
11955
+ const client = await connectSharedClient(cfg);
11956
+ const companies = await client.listCompanies();
11957
+ const normalized = (Array.isArray(companies) ? companies : []).filter((c) => c && typeof c.id === "string").map((c) => ({
11958
+ id: c.id,
11959
+ name: typeof c.name === "string" ? c.name : "",
11960
+ description: typeof c.description === "string" ? c.description : ""
11961
+ }));
11962
+ return { companies: normalized };
11963
+ } catch (err) {
11964
+ return { error: err instanceof Error ? err.message : String(err) };
11965
+ }
11966
+ });
11918
11967
  ctx.actions.register("ai-chat", async (params) => {
11919
11968
  try {
11920
11969
  if (params.mode === "poll") {
@@ -11980,9 +12029,7 @@ var plugin = definePlugin({
11980
12029
  };
11981
12030
  try {
11982
12031
  const cfg = await ctx.config.get() ?? {};
11983
- const paperclipUrl = cfg.paperclipUrl || process.env.PAPERCLIP_PUBLIC_URL || "http://localhost:3100";
11984
12032
  const paperclipEmail = cfg.paperclipEmail || "";
11985
- const paperclipPassword = cfg.paperclipPassword || "";
11986
12033
  const enableIsolatedWorktrees = await resolveEnableIsolatedWorkspacesFromInstance(cfg, log);
11987
12034
  const enableEnrichedPersonas = true;
11988
12035
  const companyName = typeof params.companyName === "string" ? params.companyName.trim() : "";
@@ -12006,11 +12053,7 @@ var plugin = definePlugin({
12006
12053
  const goals = collectGoals(selectedPreset, allModules, new Set(effectiveModules));
12007
12054
  const presetBootstrapData = collectPresetBootstrapData(selectedPreset);
12008
12055
  log("Connecting to Paperclip API...");
12009
- const client = new PaperclipClient(paperclipUrl, {
12010
- email: paperclipEmail,
12011
- password: paperclipPassword
12012
- });
12013
- await client.connect();
12056
+ const client = await connectSharedClient(cfg);
12014
12057
  log("Connected.");
12015
12058
  const gitIdentity = {
12016
12059
  name: client.boardUserName || null,
@@ -12530,7 +12573,7 @@ var plugin = definePlugin({
12530
12573
  return {
12531
12574
  companyId,
12532
12575
  issuePrefix: company.issuePrefix,
12533
- paperclipUrl,
12576
+ paperclipUrl: client.baseUrl,
12534
12577
  agentIds: { ceo: ceoAgentId, ...teamAgentIds },
12535
12578
  issueIds,
12536
12579
  logs