@openape/apes 1.10.0 → 1.12.0

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.d.ts CHANGED
@@ -348,4 +348,92 @@ declare class CliExit extends Error {
348
348
  constructor(exitCode?: number);
349
349
  }
350
350
 
351
- export { type AdapterMeta, type ApesConfig, ApiError, type AuthData, type BuiltGrantRequest, CliError, CliExit, type GrantRequestOptions, type LoadedAdapter, type RegistryEntry, type RegistryIndex, type ResolvedCapability, type ResolvedCommand, type ShapesAdapter, type ShapesOperation, apiFetch, appendAuditLog, buildExactCommandGrantRequest, buildStructuredCliGrantRequest, clearAuth, createShapesGrant, discoverEndpoints, extractOption, extractShellCommandString, extractWrappedCommand, fetchGrantToken, fetchRegistry, findAdapter, findConflictingAdapters, findExistingGrant, getAuthToken, getIdpUrl, getInstalledDigest, getRequesterIdentity, installAdapter, isInstalled, loadAdapter, loadAuth, loadConfig, loadOrInstallAdapter, parseDuration, parseShellCommand, removeAdapter, resolveAdapterPath, resolveCapabilityRequest, resolveCommand, saveAuth, saveConfig, searchAdapters, tryLoadAdapter, verifyAndExecute, waitForGrantStatus };
351
+ interface ToolDefinition {
352
+ name: string;
353
+ description: string;
354
+ parameters: Record<string, unknown>;
355
+ execute: (args: unknown) => Promise<unknown>;
356
+ }
357
+ declare const TOOLS: Record<string, ToolDefinition>;
358
+ /**
359
+ * Resolve a task spec's tool name list to ToolDefinitions. Throws on
360
+ * unknown names — callers must surface that as a run-failure with a
361
+ * clear "unknown tool: foo" final_message so the owner can see what
362
+ * went wrong in the SP UI.
363
+ */
364
+ declare function taskTools(names: string[]): ToolDefinition[];
365
+
366
+ interface ChatMessage {
367
+ role: 'system' | 'user' | 'assistant' | 'tool';
368
+ content: string | null;
369
+ tool_calls?: Array<{
370
+ id: string;
371
+ type: 'function';
372
+ function: {
373
+ name: string;
374
+ arguments: string;
375
+ };
376
+ }>;
377
+ tool_call_id?: string;
378
+ name?: string;
379
+ }
380
+ interface RuntimeConfig {
381
+ apiBase: string;
382
+ apiKey: string;
383
+ model: string;
384
+ }
385
+ interface TraceEntry {
386
+ step: number;
387
+ type: 'assistant' | 'tool_call' | 'tool_result' | 'tool_error';
388
+ preview: string;
389
+ tool?: string;
390
+ }
391
+ interface RunResult {
392
+ status: 'ok' | 'error';
393
+ finalMessage: string | null;
394
+ stepCount: number;
395
+ trace: TraceEntry[];
396
+ }
397
+ interface RunStreamHandlers {
398
+ onTextDelta?: (delta: string) => void;
399
+ onToolCall?: (call: {
400
+ name: string;
401
+ args: unknown;
402
+ }) => void;
403
+ onToolResult?: (result: {
404
+ name: string;
405
+ result: unknown;
406
+ }) => void;
407
+ onToolError?: (err: {
408
+ name: string;
409
+ error: string;
410
+ }) => void;
411
+ onDone?: (result: RunResult) => void;
412
+ }
413
+ interface RunOptions {
414
+ config: RuntimeConfig;
415
+ systemPrompt: string;
416
+ userMessage: string;
417
+ tools: ToolDefinition[];
418
+ maxSteps: number;
419
+ history?: ChatMessage[];
420
+ handlers?: RunStreamHandlers;
421
+ fetchImpl?: typeof fetch;
422
+ }
423
+ declare function runLoop(opts: RunOptions): Promise<RunResult>;
424
+ interface RpcSession {
425
+ messages: ChatMessage[];
426
+ systemPrompt: string;
427
+ tools: ToolDefinition[];
428
+ maxSteps: number;
429
+ lastTouched: number;
430
+ }
431
+ declare class RpcSessionMap {
432
+ private sessions;
433
+ get(id: string): RpcSession | undefined;
434
+ put(id: string, s: RpcSession): void;
435
+ evictStale(): void;
436
+ size(): number;
437
+ }
438
+
439
+ export { type AdapterMeta, type ApesConfig, ApiError, type AuthData, type BuiltGrantRequest, type ChatMessage, CliError, CliExit, type GrantRequestOptions, type LoadedAdapter, type RegistryEntry, type RegistryIndex, type ResolvedCapability, type ResolvedCommand, RpcSessionMap, type RunOptions, type RunResult, type RunStreamHandlers, type RuntimeConfig, type ShapesAdapter, type ShapesOperation, TOOLS, type ToolDefinition, type TraceEntry, apiFetch, appendAuditLog, buildExactCommandGrantRequest, buildStructuredCliGrantRequest, clearAuth, createShapesGrant, discoverEndpoints, extractOption, extractShellCommandString, extractWrappedCommand, fetchGrantToken, fetchRegistry, findAdapter, findConflictingAdapters, findExistingGrant, getAuthToken, getIdpUrl, getInstalledDigest, getRequesterIdentity, installAdapter, isInstalled, loadAdapter, loadAuth, loadConfig, loadOrInstallAdapter, parseDuration, parseShellCommand, removeAdapter, resolveAdapterPath, resolveCapabilityRequest, resolveCommand, runLoop, saveAuth, saveConfig, searchAdapters, taskTools, tryLoadAdapter, verifyAndExecute, waitForGrantStatus };
package/dist/index.js CHANGED
@@ -2,8 +2,12 @@
2
2
  import {
3
3
  CliError,
4
4
  CliExit,
5
- parseDuration
6
- } from "./chunk-ZSJU7IXE.js";
5
+ RpcSessionMap,
6
+ TOOLS,
7
+ parseDuration,
8
+ runLoop,
9
+ taskTools
10
+ } from "./chunk-TDSCDH5P.js";
7
11
  import {
8
12
  appendAuditLog,
9
13
  buildExactCommandGrantRequest,
@@ -52,6 +56,8 @@ export {
52
56
  ApiError,
53
57
  CliError,
54
58
  CliExit,
59
+ RpcSessionMap,
60
+ TOOLS,
55
61
  apiFetch,
56
62
  appendAuditLog,
57
63
  buildExactCommandGrantRequest,
@@ -83,9 +89,11 @@ export {
83
89
  resolveAdapterPath,
84
90
  resolveCapabilityRequest,
85
91
  resolveCommand,
92
+ runLoop,
86
93
  saveAuth,
87
94
  saveConfig,
88
95
  searchAdapters,
96
+ taskTools,
89
97
  tryLoadAdapter,
90
98
  verifyAndExecute,
91
99
  waitForGrantStatus
@@ -304,7 +304,7 @@ function registerAdapterTools(server) {
304
304
  async function startMcpServer(transport, port) {
305
305
  const server = new McpServer({
306
306
  name: "apes",
307
- version: true ? "1.10.0" : "0.1.0"
307
+ version: true ? "1.12.0" : "0.1.0"
308
308
  });
309
309
  registerStaticTools(server);
310
310
  registerAdapterTools(server);
@@ -332,4 +332,4 @@ async function startMcpServer(transport, port) {
332
332
  export {
333
333
  startMcpServer
334
334
  };
335
- //# sourceMappingURL=server-AZOEKT55.js.map
335
+ //# sourceMappingURL=server-TGGXHP4H.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openape/apes",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "turbo": {
5
5
  "tags": [
6
6
  "publishable"
@@ -31,9 +31,9 @@
31
31
  "@lydell/node-pty": "1.2.0-beta.12",
32
32
  "shell-quote": "^1.8.3",
33
33
  "zod": "^4.3.6",
34
- "@openape/proxy": "0.4.3",
34
+ "@openape/core": "0.16.0",
35
35
  "@openape/grants": "0.11.5",
36
- "@openape/core": "0.16.0"
36
+ "@openape/proxy": "0.4.3"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^25.3.5",
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/errors.ts
4
- var CliError = class extends Error {
5
- constructor(message, exitCode = 1) {
6
- super(message);
7
- this.exitCode = exitCode;
8
- this.name = "CliError";
9
- }
10
- };
11
- var CliExit = class extends Error {
12
- constructor(exitCode = 0) {
13
- super("");
14
- this.exitCode = exitCode;
15
- this.name = "CliExit";
16
- }
17
- };
18
-
19
- // src/duration.ts
20
- function parseDuration(value) {
21
- const match = value.match(/^(\d+)\s*([smhd])$/);
22
- if (!match) {
23
- throw new Error(`Invalid duration format: "${value}". Use e.g. 30m, 1h, 7d`);
24
- }
25
- const amount = Number.parseInt(match[1], 10);
26
- switch (match[2]) {
27
- case "s":
28
- return amount;
29
- case "m":
30
- return amount * 60;
31
- case "h":
32
- return amount * 3600;
33
- case "d":
34
- return amount * 86400;
35
- default:
36
- throw new Error(`Unknown duration unit: ${match[2]}`);
37
- }
38
- }
39
-
40
- export {
41
- CliError,
42
- CliExit,
43
- parseDuration
44
- };
45
- //# sourceMappingURL=chunk-ZSJU7IXE.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/duration.ts"],"sourcesContent":["export class CliError extends Error {\n constructor(message: string, public exitCode: number = 1) {\n super(message)\n this.name = 'CliError'\n }\n}\n\nexport class CliExit extends Error {\n constructor(public exitCode: number = 0) {\n super('')\n this.name = 'CliExit'\n }\n}\n","/**\n * Parse a human-readable duration string into seconds.\n * Supported formats: 30s, 5m, 1h, 7d\n */\nexport function parseDuration(value: string): number {\n const match = value.match(/^(\\d+)\\s*([smhd])$/)\n if (!match) {\n throw new Error(`Invalid duration format: \"${value}\". Use e.g. 30m, 1h, 7d`)\n }\n const amount = Number.parseInt(match[1]!, 10)\n switch (match[2]) {\n case 's': return amount\n case 'm': return amount * 60\n case 'h': return amount * 3600\n case 'd': return amount * 86400\n default: throw new Error(`Unknown duration unit: ${match[2]}`)\n }\n}\n"],"mappings":";;;AAAO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YAAY,SAAwB,WAAmB,GAAG;AACxD,UAAM,OAAO;AADqB;AAElC,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,UAAN,cAAsB,MAAM;AAAA,EACjC,YAAmB,WAAmB,GAAG;AACvC,UAAM,EAAE;AADS;AAEjB,SAAK,OAAO;AAAA,EACd;AACF;;;ACRO,SAAS,cAAc,OAAuB;AACnD,QAAM,QAAQ,MAAM,MAAM,oBAAoB;AAC9C,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,6BAA6B,KAAK,yBAAyB;AAAA,EAC7E;AACA,QAAM,SAAS,OAAO,SAAS,MAAM,CAAC,GAAI,EAAE;AAC5C,UAAQ,MAAM,CAAC,GAAG;AAAA,IAChB,KAAK;AAAK,aAAO;AAAA,IACjB,KAAK;AAAK,aAAO,SAAS;AAAA,IAC1B,KAAK;AAAK,aAAO,SAAS;AAAA,IAC1B,KAAK;AAAK,aAAO,SAAS;AAAA,IAC1B;AAAS,YAAM,IAAI,MAAM,0BAA0B,MAAM,CAAC,CAAC,EAAE;AAAA,EAC/D;AACF;","names":[]}