ns-omp-provider 0.3.0 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1
4
+
5
+ Bundles `@ngosangns/ns-pi-provider@0.2.2`.
6
+
7
+ - fix(grok): Grok's own tool activity is now visible in OMP. The Grok agent edits
8
+ files and runs commands inside its own ACP process; those tools were dropped, so
9
+ turns looked like read-only reasoning even when files changed. Each tool now shows
10
+ as a line in the reply (`` - Edit `src/a.ts` (+3 −1) ``, `` - Run `npm test` ``,
11
+ `✗ … failed`). Text only — OMP never re-runs them. `PI_GROK_SDK_SHOW_TOOLS=0` hides.
12
+ - fix(grok): cold-start prompts carry a short bridge note so Grok acts with its
13
+ built-in tools instead of describing OMP tool calls (`PI_GROK_SDK_BRIDGE_NOTE=0`
14
+ disables).
15
+
3
16
  ## 0.3.0
4
17
 
5
18
  - **Breaking: `kiro` is now opt-in.** By default only `devin` and `grok` (+ `grok-sdk`)
package/README.md CHANGED
@@ -88,7 +88,7 @@ register the same `kiro` provider id.
88
88
  (since ns-pi-provider 0.2.0): with no Kiro credential and no saved catalog
89
89
  snapshot, `kiro` registers zero models, and `-1m` long-context variants are
90
90
  not offered.
91
- - **Upstream pin** — this release bundles `@ngosangns/ns-pi-provider@0.2.1`.
91
+ - **Upstream pin** — this release bundles `@ngosangns/ns-pi-provider@0.2.2`.
92
92
  Bumping it is a deliberate change (rebuild + retest).
93
93
 
94
94
  ## Development
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // ns-omp-provider 0.3.0 — bundles @ngosangns/ns-pi-provider@0.2.1 (MIT). See NOTICE.
1
+ // ns-omp-provider 0.3.1 — bundles @ngosangns/ns-pi-provider@0.2.2 (MIT). See NOTICE.
2
2
  import { createRequire as __nsOmpCreateRequire } from 'node:module';
3
3
  const require = __nsOmpCreateRequire(import.meta.url);
4
4
  var __defProp = Object.defineProperty;
@@ -3798,9 +3798,14 @@ function mapReasoningEffort(reasoning) {
3798
3798
  }
3799
3799
  return void 0;
3800
3800
  }
3801
- function envFlag(name, env = process.env) {
3802
- const v = env[name];
3803
- return v === "1" || v === "true" || v === "yes";
3801
+ function envFlagDefault(names, fallback, env = process.env) {
3802
+ for (const name of names) {
3803
+ const raw = env[name]?.trim().toLowerCase();
3804
+ if (!raw) continue;
3805
+ if (raw === "1" || raw === "true" || raw === "yes" || raw === "on") return true;
3806
+ if (raw === "0" || raw === "false" || raw === "no" || raw === "off") return false;
3807
+ }
3808
+ return fallback;
3804
3809
  }
3805
3810
 
3806
3811
  // node_modules/@ngosangns/ns-pi-provider/src/grok/models.ts
@@ -3985,6 +3990,8 @@ var PiContentEmitter = class {
3985
3990
  started = false;
3986
3991
  thinkingContentIndex = -1;
3987
3992
  textContentIndex = -1;
3993
+ /** Last visible text appended was a tool-activity list line. */
3994
+ lastTextWasTool = false;
3988
3995
  mutuallyExclusive;
3989
3996
  /** Current immutable view (for external reads). */
3990
3997
  snapshot() {
@@ -4025,6 +4032,7 @@ var PiContentEmitter = class {
4025
4032
  const contentIndex = this.textContentIndex;
4026
4033
  const block = this.partial.content[contentIndex];
4027
4034
  this.textContentIndex = -1;
4035
+ this.lastTextWasTool = false;
4028
4036
  if (block?.type !== "text") return "";
4029
4037
  this.push({
4030
4038
  type: "text_end",
@@ -4063,6 +4071,32 @@ var PiContentEmitter = class {
4063
4071
  }
4064
4072
  appendText(delta, options) {
4065
4073
  if (!delta) return;
4074
+ if (this.lastTextWasTool && this.textContentIndex >= 0) {
4075
+ this.lastTextWasTool = false;
4076
+ const open = this.partial.content[this.textContentIndex];
4077
+ if (open?.type === "text" && !open.text.endsWith("\n\n")) {
4078
+ delta = `${open.text.endsWith("\n") ? "\n" : "\n\n"}${delta}`;
4079
+ }
4080
+ }
4081
+ this.lastTextWasTool = false;
4082
+ this.appendTextRaw(delta, options);
4083
+ }
4084
+ /**
4085
+ * Visible tool-activity line(s) ("- Edit `a.ts` (+1 −1)\n") in the answer
4086
+ * text, separated from surrounding prose so Markdown renders them as a list.
4087
+ */
4088
+ appendToolActivity(lines, options) {
4089
+ if (!lines) return;
4090
+ let delta = lines.endsWith("\n") ? lines : `${lines}
4091
+ `;
4092
+ const open = this.textContentIndex >= 0 ? this.partial.content[this.textContentIndex] : void 0;
4093
+ if (!this.lastTextWasTool && open?.type === "text" && open.text && !open.text.endsWith("\n\n")) {
4094
+ delta = `${open.text.endsWith("\n") ? "\n" : "\n\n"}${delta}`;
4095
+ }
4096
+ this.appendTextRaw(delta, options);
4097
+ this.lastTextWasTool = true;
4098
+ }
4099
+ appendTextRaw(delta, options) {
4066
4100
  this.ensureStart();
4067
4101
  if (options?.closeThinking ?? this.mutuallyExclusive) this.closeThinking();
4068
4102
  if (this.textContentIndex < 0) {
@@ -4187,6 +4221,15 @@ var StreamingUpdatePump = class {
4187
4221
 
4188
4222
  // node_modules/@ngosangns/ns-pi-provider/src/grok/prompt.ts
4189
4223
  init_pi_ai();
4224
+ var GROK_BRIDGE_NOTE = [
4225
+ "[grok bridge] You are the Grok coding agent, running behind an external coding harness that only relays your messages.",
4226
+ "Tools named in the harness instructions below (read, bash, edit, write, \u2026) are not callable from here.",
4227
+ "Use your own built-in tools (read_file, grep, search_replace, write, run_terminal_command, \u2026) directly in the working directory.",
4228
+ "When the task needs file changes or commands, perform them with those tools instead of describing them or writing tool calls as text."
4229
+ ].join("\n");
4230
+ function bridgeNoteEnabled() {
4231
+ return envFlagDefault(["PI_GROK_SDK_BRIDGE_NOTE"], true);
4232
+ }
4190
4233
  function contentToText(content) {
4191
4234
  if (typeof content === "string") return content;
4192
4235
  if (!Array.isArray(content)) return "";
@@ -4223,6 +4266,7 @@ ${contentToText(message2.content)}`);
4223
4266
  ${contentToText(message2.content)}`);
4224
4267
  }
4225
4268
  }
4269
+ if (parts.length > 0 && bridgeNoteEnabled()) parts.unshift(GROK_BRIDGE_NOTE);
4226
4270
  return parts.join("\n\n");
4227
4271
  }
4228
4272
  function buildIncrementalPrompt(context) {
@@ -4669,6 +4713,140 @@ async function withSessionAgent(params, fn) {
4669
4713
  });
4670
4714
  }
4671
4715
 
4716
+ // node_modules/@ngosangns/ns-pi-provider/src/grok/tool-activity.ts
4717
+ var MAX_LABEL = 160;
4718
+ function toolMeta(update) {
4719
+ const meta = update._meta?.["x.ai/tool"];
4720
+ if (!meta || typeof meta !== "object") return {};
4721
+ const m = meta;
4722
+ return {
4723
+ name: typeof m.name === "string" ? m.name : void 0,
4724
+ kind: typeof m.kind === "string" ? m.kind : void 0,
4725
+ label: typeof m.label === "string" ? m.label : void 0
4726
+ };
4727
+ }
4728
+ function oneLine(text2, max = MAX_LABEL) {
4729
+ const flat = text2.replace(/\s*\n\s*/g, " \u23CE ").replace(/\s+/g, " ").trim();
4730
+ return flat.length > max ? `${flat.slice(0, max - 1)}\u2026` : flat;
4731
+ }
4732
+ function countLines(text2) {
4733
+ if (typeof text2 !== "string" || text2.length === 0) return 0;
4734
+ const body = text2.endsWith("\n") ? text2.slice(0, -1) : text2;
4735
+ return body.split("\n").length;
4736
+ }
4737
+ function diffStat(content) {
4738
+ if (!Array.isArray(content)) return "";
4739
+ let added = 0;
4740
+ let removed = 0;
4741
+ let seen = false;
4742
+ for (const item of content) {
4743
+ if (!item || typeof item !== "object") continue;
4744
+ const c = item;
4745
+ if (c.type !== "diff") continue;
4746
+ seen = true;
4747
+ added += countLines(c.newText);
4748
+ removed += countLines(c.oldText);
4749
+ }
4750
+ return seen ? `+${added} \u2212${removed}` : "";
4751
+ }
4752
+ function firstText(content) {
4753
+ if (!Array.isArray(content)) return "";
4754
+ for (const item of content) {
4755
+ if (!item || typeof item !== "object") continue;
4756
+ const c = item;
4757
+ const inner = c.content;
4758
+ if (c.type === "content" && inner && typeof inner.text === "string" && inner.text.trim()) {
4759
+ return inner.text;
4760
+ }
4761
+ }
4762
+ return "";
4763
+ }
4764
+ var ToolActivityTracker = class {
4765
+ constructor(cwd) {
4766
+ this.cwd = cwd;
4767
+ }
4768
+ cwd;
4769
+ tools = /* @__PURE__ */ new Map();
4770
+ relativize(text2) {
4771
+ const cwd = this.cwd?.replace(/\/+$/, "");
4772
+ if (!cwd || cwd === "/") return text2;
4773
+ let out = text2;
4774
+ const roots = /* @__PURE__ */ new Set([cwd, cwd.replace(/^\/private\//, "/")]);
4775
+ for (const root of [...roots]) roots.add(`/private${root}`);
4776
+ for (const root of [...roots].sort((a, b) => b.length - a.length)) {
4777
+ out = out.split(`${root}/`).join("");
4778
+ out = out.split(`\`${root}\``).join("`.`");
4779
+ }
4780
+ return out;
4781
+ }
4782
+ describe(entry) {
4783
+ const input = entry.rawInput ?? {};
4784
+ let label;
4785
+ if (entry.kind === "execute" && typeof input.command === "string") {
4786
+ label = `Run \`${oneLine(String(input.command), MAX_LABEL - 8)}\``;
4787
+ } else if (entry.title && entry.title !== entry.name) {
4788
+ label = oneLine(entry.title);
4789
+ } else {
4790
+ const verb = entry.label ?? entry.name ?? "Tool";
4791
+ const target = typeof input.file_path === "string" && input.file_path || typeof input.target_file === "string" && input.target_file || typeof input.path === "string" && input.path || typeof input.pattern === "string" && input.pattern || typeof input.query === "string" && input.query || "";
4792
+ label = target ? `${verb} \`${oneLine(String(target), MAX_LABEL - 8)}\`` : verb;
4793
+ }
4794
+ return this.relativize(label);
4795
+ }
4796
+ /**
4797
+ * Feed one ACP `session/update`. Returns Markdown line(s) to show (each
4798
+ * ending in "\n"), or undefined when nothing new is visible yet.
4799
+ */
4800
+ handle(update) {
4801
+ const kind = update.sessionUpdate;
4802
+ if (kind !== "tool_call" && kind !== "tool_call_update") return void 0;
4803
+ const id = update.toolCallId;
4804
+ if (!id) return void 0;
4805
+ let entry = this.tools.get(id);
4806
+ if (!entry) {
4807
+ entry = { announced: false, finished: false };
4808
+ this.tools.set(id, entry);
4809
+ }
4810
+ const meta = toolMeta(update);
4811
+ entry.name ??= meta.name ?? (kind === "tool_call" ? update.title : void 0);
4812
+ entry.label ??= meta.label;
4813
+ if (meta.kind) entry.kind = meta.kind === "write" ? "edit" : meta.kind;
4814
+ if (update.kind) entry.kind = update.kind;
4815
+ if (update.rawInput && typeof update.rawInput === "object") {
4816
+ entry.rawInput = { ...entry.rawInput ?? {}, ...update.rawInput };
4817
+ }
4818
+ if (update.title) entry.title = update.title;
4819
+ if (entry.finished) return void 0;
4820
+ const lines = [];
4821
+ const status = update.status;
4822
+ const done = status === "completed" || status === "failed";
4823
+ const stat = diffStat(update.content);
4824
+ if (stat) entry.stat = stat;
4825
+ const isEdit = entry.kind === "edit" || entry.kind === "delete" || entry.kind === "move";
4826
+ const enriched = kind === "tool_call_update" && Boolean(update.title || update.kind);
4827
+ const ready = isEdit ? done : enriched || done || status === "in_progress";
4828
+ if (!entry.announced && ready) {
4829
+ entry.announced = true;
4830
+ lines.push(`- ${this.describe(entry)}${isEdit && entry.stat ? ` (${entry.stat})` : ""}`);
4831
+ if (done) {
4832
+ entry.finished = true;
4833
+ if (status === "failed") lines.push(` - \u2717 failed${this.failureDetail(update)}`);
4834
+ }
4835
+ } else if (entry.announced && done) {
4836
+ entry.finished = true;
4837
+ if (status === "failed") {
4838
+ lines.push(` - \u2717 ${this.describe(entry)} failed${this.failureDetail(update)}`);
4839
+ }
4840
+ }
4841
+ return lines.length ? `${lines.join("\n")}
4842
+ ` : void 0;
4843
+ }
4844
+ failureDetail(update) {
4845
+ const text2 = firstText(update.content);
4846
+ return text2 ? `: ${this.relativize(oneLine(text2, 200))}` : "";
4847
+ }
4848
+ };
4849
+
4672
4850
  // node_modules/@ngosangns/ns-pi-provider/src/grok/acp-mode.ts
4673
4851
  function streamViaAcp(model, context, options) {
4674
4852
  const stream = createAssistantMessageEventStream();
@@ -4698,7 +4876,11 @@ function streamViaAcp(model, context, options) {
4698
4876
  }
4699
4877
  const reasoning = mapReasoningEffort(options?.reasoning);
4700
4878
  const cwd = getSessionCwd();
4701
- const showTools = envFlag("PI_GROK_SDK_SHOW_TOOLS") || envFlag("PI_GROK_AGENT_SHOW_TOOLS");
4879
+ const showTools = envFlagDefault(
4880
+ ["PI_GROK_SDK_SHOW_TOOLS", "PI_GROK_AGENT_SHOW_TOOLS"],
4881
+ true
4882
+ );
4883
+ const tools = new ToolActivityTracker(cwd);
4702
4884
  const cliModelId = resolveCliModelId(model.id);
4703
4885
  emitter.ensureStart();
4704
4886
  await withSessionAgent(
@@ -4726,9 +4908,9 @@ function streamViaAcp(model, context, options) {
4726
4908
  emitter.appendThinking(piece);
4727
4909
  } else if (kind === "agent_message_chunk") {
4728
4910
  emitter.appendText(piece);
4729
- } else if (showTools && kind === "tool_call") {
4730
- const label = update.title || update.kind || "tool";
4731
- emitter.noteActivity(`[grok tool: ${label}]`);
4911
+ } else if (showTools && (kind === "tool_call" || kind === "tool_call_update")) {
4912
+ const lines = tools.handle(update);
4913
+ if (lines) emitter.appendToolActivity(lines);
4732
4914
  }
4733
4915
  });
4734
4916
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ns-omp-provider",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "OMP (oh-my-pi) plugin: Kiro, Devin, and Grok providers from @ngosangns/ns-pi-provider, wrapped for OMP's provider/extension API.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -70,7 +70,7 @@
70
70
  }
71
71
  },
72
72
  "devDependencies": {
73
- "@ngosangns/ns-pi-provider": "0.2.1",
73
+ "@ngosangns/ns-pi-provider": "0.2.2",
74
74
  "@types/node": "^22.18.6",
75
75
  "esbuild": "^0.28.2",
76
76
  "typescript": "^5.9.2",