@rzx/ohs 1.0.7 → 1.0.14

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/README.md CHANGED
@@ -8,7 +8,7 @@ OpenHarness-ts 终端 CLI:在终端里跑 AI Agent。默认进入交互式 TUI
8
8
 
9
9
  - Node.js >= 20
10
10
  - 交互式 TUI:额外安装 [Bun](https://bun.sh)
11
- - 可选:Docker(启用 sandbox 时)
11
+ - 可选:SRT(启用本机 sandbox 时);Windows 可选择 WSL 作为 Agent 运行环境
12
12
 
13
13
  ## 安装
14
14
 
@@ -88,7 +88,7 @@ ohs auth status
88
88
  ohs provider list|use|add|edit|remove
89
89
  ohs mcp list|add|remove
90
90
  ohs plugin list|install|uninstall|enable|disable
91
- ohs sandbox on|off|status|doctor
91
+ ohs sandbox enable|disable|status|check
92
92
  ohs daemon start|status|stop|install|uninstall
93
93
  ohs config show
94
94
  ohs config set <key> <value>
@@ -117,4 +117,4 @@ ohs config set daemon.autoStart true
117
117
  - 项目文档:[https://github.com/rzx007/openharness-ts/tree/main/docs](https://github.com/rzx007/openharness-ts/tree/main/docs)
118
118
  - 问题反馈:[https://github.com/rzx007/openharness-ts/issues](https://github.com/rzx007/openharness-ts/issues)
119
119
 
120
- 本地从源码开发请看仓库根目录 `README.md`。
120
+ 本地从源码开发请看仓库根目录 `README.md`。
@@ -118,7 +118,15 @@ var init_builtinThemes = __esm(() => {
118
118
  });
119
119
 
120
120
  // ../../packages/protocol/src/session.ts
121
- var SESSION_EVENT_SCHEMA_VERSION = 1;
121
+ function sessionEventSchemaVersion(type) {
122
+ return SESSION_EVENT_SCHEMA_VERSIONS[type] ?? SESSION_EVENT_SCHEMA_VERSION;
123
+ }
124
+ var SESSION_EVENT_SCHEMA_VERSION = 1, SESSION_EVENT_SCHEMA_VERSIONS;
125
+ var init_session = __esm(() => {
126
+ SESSION_EVENT_SCHEMA_VERSIONS = {
127
+ "session.input.admitted": 2
128
+ };
129
+ });
122
130
 
123
131
  // ../../packages/protocol/src/runtime-config.ts
124
132
  function isRecord(value) {
@@ -189,8 +197,22 @@ function stripUndefined(input) {
189
197
  return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== undefined));
190
198
  }
191
199
 
200
+ // ../../packages/protocol/src/session-input-items.ts
201
+ var SESSION_INPUT_LIMITS;
202
+ var init_session_input_items = __esm(() => {
203
+ SESSION_INPUT_LIMITS = {
204
+ maxItems: 256,
205
+ maxSkills: 32,
206
+ maxTextBytes: 1024 * 1024,
207
+ maxNameChars: 128,
208
+ maxDisplayNameChars: 256
209
+ };
210
+ });
211
+
192
212
  // ../../packages/protocol/src/requests.ts
193
- var init_requests = () => {};
213
+ var init_requests = __esm(() => {
214
+ init_session_input_items();
215
+ });
194
216
  // ../../packages/protocol/src/serialization.ts
195
217
  function object(value, path) {
196
218
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -504,13 +526,29 @@ function decodeJobWaitResult(value) {
504
526
  }
505
527
  function decodeTerminalSessionInfo(value) {
506
528
  const terminal = object(value, "terminal");
507
- for (const field of ["id", "name", "projectId", "cwd", "shell", "createdAt"]) {
529
+ for (const field of ["id", "name", "cwd", "shell", "createdAt"]) {
508
530
  stringField(terminal, field, "terminal");
509
531
  }
510
- enumField(terminal, "runtime", "terminal", ["local", "sandbox"]);
532
+ const scope = recordField(terminal, "scope", "terminal");
533
+ const scopeKind = enumField(scope, "kind", "terminal.scope", ["project", "session"]);
534
+ if (scopeKind === "project") {
535
+ const projectId = stringField(scope, "projectId", "terminal.scope");
536
+ optionalString(terminal, "projectId", "terminal");
537
+ if (terminal.projectId !== undefined && terminal.projectId !== projectId) {
538
+ throw new ProtocolDataError("terminal.projectId must match terminal.scope.projectId", "terminal.projectId");
539
+ }
540
+ } else {
541
+ const sessionId = stringField(scope, "sessionId", "terminal.scope");
542
+ optionalString(terminal, "sessionId", "terminal");
543
+ if (terminal.sessionId !== undefined && terminal.sessionId !== sessionId) {
544
+ throw new ProtocolDataError("terminal.sessionId must match terminal.scope.sessionId", "terminal.sessionId");
545
+ }
546
+ }
547
+ optionalString(terminal, "projectId", "terminal");
548
+ optionalString(terminal, "sessionId", "terminal");
549
+ enumField(terminal, "runtime", "terminal", ["local", "environment"]);
511
550
  enumField(terminal, "source", "terminal", ["user", "agent"]);
512
551
  enumField(terminal, "status", "terminal", ["running", "stopping", "completed", "killed", "failed"]);
513
- optionalString(terminal, "sessionId", "terminal");
514
552
  numberField(terminal, "cols", "terminal");
515
553
  numberField(terminal, "rows", "terminal");
516
554
  optionalString(terminal, "exitedAt", "terminal");
@@ -752,10 +790,12 @@ var init_capabilities = __esm(() => {
752
790
 
753
791
  // ../../packages/protocol/src/index.ts
754
792
  var init_src = __esm(() => {
793
+ init_session();
755
794
  init_requests();
756
795
  init_serialization();
757
796
  init_capabilities();
758
797
  init_attachment();
798
+ init_session_input_items();
759
799
  });
760
800
 
761
801
  // ../../packages/client/src/transport/http-client.ts
@@ -1074,6 +1114,20 @@ class OpenHarnessClient {
1074
1114
  async installLocalPlugin(input) {
1075
1115
  return await this.request(input.link ? "/plugins/link-local" : "/plugins/install-local", { method: "POST", body: input });
1076
1116
  }
1117
+ async previewPluginArchive(input, options = {}) {
1118
+ return await this.request("/plugins/archive/preview", {
1119
+ method: "POST",
1120
+ body: input,
1121
+ signal: options.signal
1122
+ });
1123
+ }
1124
+ async installPluginArchive(input, options = {}) {
1125
+ return await this.request("/plugins/archive/install", {
1126
+ method: "POST",
1127
+ body: input,
1128
+ signal: options.signal
1129
+ });
1130
+ }
1077
1131
  async uninstallPlugin(id, input) {
1078
1132
  return await this.request(`/plugins/${encodeURIComponent(id)}`, { method: "DELETE", body: input });
1079
1133
  }
@@ -1084,6 +1138,18 @@ class OpenHarnessClient {
1084
1138
  signal: options.signal
1085
1139
  });
1086
1140
  }
1141
+ async listSkills(options = {}) {
1142
+ return await this.request("/skills", {
1143
+ signal: options.signal
1144
+ });
1145
+ }
1146
+ async removeSkill(id, input, options = {}) {
1147
+ return await this.request(`/skills/${encodeURIComponent(id)}`, {
1148
+ method: "DELETE",
1149
+ body: input,
1150
+ signal: options.signal
1151
+ });
1152
+ }
1087
1153
  async listAgentPersonas(options = {}) {
1088
1154
  const response = await this.request("/agent-personas", {
1089
1155
  signal: options.signal
@@ -1614,7 +1680,7 @@ function applySessionSnapshot(state, snapshot) {
1614
1680
  };
1615
1681
  }
1616
1682
  function applyEvent(state, event) {
1617
- if (event.schemaVersion !== SESSION_EVENT_SCHEMA_VERSION) {
1683
+ if (event.schemaVersion !== sessionEventSchemaVersion(event.type)) {
1618
1684
  throw new UnsupportedSessionEventSchemaVersionError(event);
1619
1685
  }
1620
1686
  const transient = event.type === "session.message.part.delta";
@@ -1891,7 +1957,8 @@ var init_reducer = __esm(() => {
1891
1957
  UnsupportedSessionEventSchemaVersionError = class UnsupportedSessionEventSchemaVersionError extends Error {
1892
1958
  event;
1893
1959
  constructor(event) {
1894
- super(`Unsupported session event schema version ${event.schemaVersion} for ${event.type} at sequence ${event.seq}; expected ${SESSION_EVENT_SCHEMA_VERSION}`);
1960
+ const expected = sessionEventSchemaVersion(event.type);
1961
+ super(`Unsupported session event schema version ${event.schemaVersion} for ${event.type} at sequence ${event.seq}; expected ${expected}`);
1895
1962
  this.name = "UnsupportedSessionEventSchemaVersionError";
1896
1963
  this.event = {
1897
1964
  seq: event.seq,
@@ -2040,6 +2107,29 @@ var init_state = __esm(() => {
2040
2107
  init_sync();
2041
2108
  });
2042
2109
 
2110
+ // ../../packages/client/src/commands/plugin-presentation.ts
2111
+ function formatPluginReload(result) {
2112
+ const lines = [result.message];
2113
+ if (!result.plugins.length)
2114
+ lines.push("No plugins discovered.");
2115
+ else {
2116
+ lines.push("Plugin validation after reload (runtimes load on next use):");
2117
+ for (const plugin of result.plugins) {
2118
+ lines.push(`- ${plugin.identity.id} [${plugin.enabled ? "enabled" : "disabled"}/${plugin.installation}/${plugin.activation}]`);
2119
+ for (const diagnostic of plugin.diagnostics)
2120
+ lines.push(` ${diagnostic.severity}: ${diagnostic.code}: ${diagnostic.message}`);
2121
+ if (plugin.permissions.missing.length)
2122
+ lines.push(` Missing permissions: ${plugin.permissions.missing.join(", ")}`);
2123
+ if (plugin.installation !== "installed" || plugin.permissions.missing.length || plugin.diagnostics.some((item) => item.code.includes("permission"))) {
2124
+ lines.push(plugin.scope === "managed" ? " Ask your administrator to repair this managed plugin." : " Review the source and permissions, then run ohs plugin install-local <source> or ohs plugin link <source>, supplying --approve <permission> for each requested permission.");
2125
+ }
2126
+ }
2127
+ }
2128
+ lines.push(...result.warnings.map((warning) => `! ${warning}`));
2129
+ return lines.join(`
2130
+ `);
2131
+ }
2132
+
2043
2133
  // ../../packages/client/src/commands/session-commands.ts
2044
2134
  function parseSlashLine(line) {
2045
2135
  const trimmed = line.trim();
@@ -2812,18 +2902,7 @@ No entries found.`;
2812
2902
  }
2813
2903
  if (slash?.name === "/reload-plugins") {
2814
2904
  const result = await client.reloadPlugins({ cwd });
2815
- if (result.plugins.length === 0) {
2816
- emit(`${result.message}
2817
- No plugins discovered.`);
2818
- return "handled";
2819
- }
2820
- emit([
2821
- result.message,
2822
- "Reloaded plugins:",
2823
- ...result.plugins.map((plugin) => `- ${plugin.identity.id} [${plugin.enabled ? "enabled" : "disabled"}]`),
2824
- ...result.warnings.map((warning) => `! ${warning}`)
2825
- ].join(`
2826
- `));
2905
+ emit(formatPluginReload(result));
2827
2906
  return "handled";
2828
2907
  }
2829
2908
  if (slash?.name === "/hooks") {
@@ -3874,7 +3953,7 @@ Refresh failed: ${message}` : `Failed to load ${request.title}: ${message}`;
3874
3953
  }
3875
3954
  const response = await client.admitPrompt(session.id, {
3876
3955
  id: createPromptRequestId(),
3877
- content: config.initial_prompt
3956
+ items: [{ type: "text", text: config.initial_prompt }]
3878
3957
  });
3879
3958
  setLocalBusy(false);
3880
3959
  setSubmittedRun(response.run ? { sessionId: session.id, runId: response.run.id } : null);
@@ -4018,19 +4097,18 @@ Refresh failed: ${message}` : `Failed to load ${request.title}: ${message}`;
4018
4097
  if (!sessionId)
4019
4098
  return;
4020
4099
  setLocalBusy(true);
4021
- const commandName = slash.name.replace(/^\//, "");
4022
4100
  const response = await client.admitPrompt(sessionId, {
4023
4101
  id: createPromptRequestId(),
4024
- content: slash.args,
4025
- metadata: {
4026
- skillInvocation: {
4027
- name: commandName,
4028
- commandName,
4102
+ items: [
4103
+ {
4104
+ type: "skill",
4105
+ name: catalogEntry.skillName,
4106
+ path: catalogEntry.path,
4029
4107
  ...catalogEntry.displayName ? { displayName: catalogEntry.displayName } : {},
4030
- source: catalogEntry.source,
4031
- invocationSource: "slash"
4032
- }
4033
- }
4108
+ ...catalogEntry.source && catalogEntry.source !== "builtin" ? { source: catalogEntry.source } : {}
4109
+ },
4110
+ ...slash.args ? [{ type: "text", text: ` ${slash.args}` }] : []
4111
+ ]
4034
4112
  });
4035
4113
  setLocalBusy(false);
4036
4114
  setSubmittedRun(response.run ? { sessionId, runId: response.run.id } : null);
@@ -4048,7 +4126,7 @@ Refresh failed: ${message}` : `Failed to load ${request.title}: ${message}`;
4048
4126
  setLocalBusy(true);
4049
4127
  const response = await client.admitPrompt(sessionId, {
4050
4128
  id: createPromptRequestId(),
4051
- content: line
4129
+ items: [{ type: "text", text: line }]
4052
4130
  });
4053
4131
  setLocalBusy(false);
4054
4132
  setSubmittedRun(response.run ? { sessionId, runId: response.run.id } : null);
@@ -8056,4 +8134,4 @@ try {
8056
8134
  process.exit(1);
8057
8135
  }
8058
8136
 
8059
- //# debugId=5DBCBBC40135AE2E64756E2164756E21
8137
+ //# debugId=DB9708E7A715BB8364756E2164756E21