jg-agent-hq 11.0.1 → 11.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 11.1.0
4
+
5
+ - Report each Codex skill's `argumentHint` from the `argument-hint` its `SKILL.md` declares. Codex's native skill list carries no hints, so a catalog read now reads the single-line frontmatter of the file at each listed skill's path, 8 files at a time, and of each skill in the operator's extra roots: a regular file of at most 65,536 bytes, without following a link at that path. A hint that is missing, empty, a block scalar or over 1,024 characters stays null, and a file that can't be read leaves only the hint null, without counting toward `unavailableCount`. Session and folder catalogs give a skill the same hint.
6
+ - Store nothing new: the schema and existing databases are unchanged.
7
+
3
8
  ## 11.0.1
4
9
 
5
10
  - Credit an explicit skill the operator sends from a browser to the operator. A browser submission recorded a fingerprint only for text, so a skill's message linked to its action as a programmatic `host-action` with an unknown origin, and a client showed the operator's own skill as sent by its host. The skill's prepared invocation, the `$name args` or `/name args` the session received, now becomes the submission's fingerprint once its action is admitted, so the message reads back as `authenticated-host-action` from the operator. Skills sent before this version keep their recorded provenance.
package/api/README.md CHANGED
@@ -314,7 +314,7 @@ Partial text uses temporary live identities until the final native message UUID
314
314
 
315
315
  `skills` accepts `provider`, `workspaceRoot`, an optional managed `threadId`, optional `search`, `limit` (default 32, maximum 128) and `cursor`. The folder must be inside the allowed roots. With `threadId` it reads that controlled session's catalog, and the session must run for that provider in that folder, or the request fails with JG_AGENT_HQ_REQUEST_INVALID; it never adopts or resumes an external session. Without `threadId` it reads the catalog a session started in the folder would have, with no session: Codex lists the folder, and Claude starts a session-less read process there with the trusted additional directories, reads its initialization command list and closes it, without a user prompt or model turn. A skill's ID is derived from its provider, name and path, so a folder's catalog and a session started there give the same skill the same ID while the skills don't change, and an ID from the folder's catalog can name a skill for that session's input. Codex uses native `skills/list` for the workspace, plus the skills in the operator's Codex extra roots; Claude uses the native initialization command list, which includes explicit-only skills. Its refresh endpoint omits those skills, so HQ does not use it. Close and explicitly resume the session to refresh Claude's catalog. Inactive or unsupported sessions report `unavailable`, with no successful-empty fallback. Native discovery errors produce `partial` and an `unavailableCount`. `observedAt` records when the native inventory was observed; it stays fixed for a Claude session and is null when unavailable. `invocationPrefix` is the text that starts a skill invocation in the provider's native input, `/` for Claude and `$` for Codex, and is null when unavailable; a provider adapter supplies it with its inventory in `IProviderSkills`, from `readSkills(workspaceRoot, nativeId, call)`, which reads the folder's inventory when `nativeId` is undefined.
316
316
 
317
- Rows contain an opaque `id`, native `name`, `description`, nullable `argumentHint`, `kind`, `path`, `scope`, `prerequisites` and `requiresExplicitInvocation`, plus native availability as `isEnabled`. Codex supplies skill identity, source/scope, enabled state and declared tool prerequisites. Claude supplies native command names, descriptions, argument hints and a built-in marker when available. Missing fields are null or `kind: 'unavailable'`; HQ does not inspect skill files to infer them. The one exception is Codex extra roots, which native discovery does not list: HQ reads each skill's single-line `name` and `description` frontmatter from `<root>/<directory>/SKILL.md`, reports it with scope `host`, skips linked directories and files, and counts unreadable entries in `unavailableCount`. A native skill with the same name takes precedence. Declared prerequisites are metadata, not proof that an integration is connected. Invocation rules remain with the CLI, including explicit-only skills.
317
+ Rows contain an opaque `id`, native `name`, `description`, nullable `argumentHint`, `kind`, `path`, `scope`, `prerequisites` and `requiresExplicitInvocation`, plus native availability as `isEnabled`. Codex supplies skill identity, source/scope, enabled state and declared tool prerequisites, but no argument hints, so HQ reads each listed skill's single-line `argument-hint` frontmatter from the `SKILL.md` at its reported path, 8 files at a time: a regular file of at most 65,536 bytes, without following a link at that path. A hint that is missing, empty, a block scalar or over 1,024 characters is null, and a file HQ can't read leaves only the hint null, without counting toward `unavailableCount`. Claude supplies native command names, descriptions, argument hints and a built-in marker when available. Other missing fields are null or `kind: 'unavailable'`; HQ reads skill files only for those Codex hints and for Codex extra roots, which native discovery does not list: HQ reads each skill's single-line `name`, `description` and `argument-hint` frontmatter from `<root>/<directory>/SKILL.md`, reports it with scope `host`, skips linked directories and files, and counts unreadable entries in `unavailableCount`. A native skill with the same name takes precedence. Declared prerequisites are metadata, not proof that an integration is connected. Invocation rules remain with the CLI, including explicit-only skills.
318
318
 
319
319
  Both native inventory interfaces are unpaged. HQ accepts at most 4,096 native rows and 1 MiB of normalized catalog metadata per read, then provides stable ID seek pages guarded by the complete inventory revision and query. A changed inventory invalidates continuation. Only metadata is read, never skill bodies or complete conversation histories. Concurrent reads of the same session, or of the same provider's folder, share their in-flight native request; Codex results are not retained as an HQ cache. Claude's native initialization metadata remains attached to its owned connection until that session closes. Native refresh and discovery caches remain provider-owned.
320
320
 
@@ -1,9 +1,10 @@
1
1
  import { Exception, isException } from 'jg-exception';
2
+ import { runInOrder } from 'jg-utilities';
2
3
  import { z } from 'zod';
3
4
  import { MAX_PAGE_SIZE, } from '../../contracts/index.js';
4
5
  import { NativeIdSchema } from '../../contracts/identities/index.js';
5
6
  import { decodeBase64Image, imageUnavailable, readImageFile } from '../../sessions/index.js';
6
- import { LOADED_THREADS_PAGE_SIZE, MAX_TURN_TIME_PAGES, TURN_TIMES_PAGE_SIZE, } from './constants.js';
7
+ import { LOADED_THREADS_PAGE_SIZE, MAX_TURN_TIME_PAGES, SKILL_HINT_READ_CONCURRENCY, TURN_TIMES_PAGE_SIZE, } from './constants.js';
7
8
  import { createCodexRpc } from './rpc.js';
8
9
  import { createCodexExtensions } from './extensions/index.js';
9
10
  import { createCodexAccounts } from './accounts/index.js';
@@ -13,7 +14,7 @@ import { NativeBucketSchema, NativeSkillsSchema, NativeItemPageSchema, NativeThr
13
14
  import { toHistoryItem, toImageSources, toItemDetail, toThreadSummary, toTurnSummary, toUsageSnapshot, } from './transformers.js';
14
15
  import { parseNative } from './validations.js';
15
16
  import { toCodexModels } from './models/index.js';
16
- import { HOST_SKILL_SCOPE, readSkillRoots, toCapabilityRoots } from './skill-roots/index.js';
17
+ import { HOST_SKILL_SCOPE, readSkillHint, readSkillRoots, toCapabilityRoots, } from './skill-roots/index.js';
17
18
  import { toCodexConfiguration, toCodexServiceTier, toCodexSessionSettings, readCodexConfigurationObservation, } from './configuration/index.js';
18
19
  /**
19
20
  * Connects native history, account observations and explicitly admitted runtime controls.
@@ -403,6 +404,11 @@ export const createCodexProvider = async (extraSkillRoots = [], daemonLauncher =
403
404
  kind: 'agent-unavailable',
404
405
  },
405
406
  });
407
+ // native discovery reports no argument hints, so HQ reads each listed skill file's own
408
+ const hints = await runInOrder(entry.skills, {
409
+ concurrency: SKILL_HINT_READ_CONCURRENCY,
410
+ execute: (skill) => readSkillHint(skill.path),
411
+ });
406
412
  // native discovery never lists a thread's capability roots, so HQ adds its own; native wins
407
413
  const roots = await readSkillRoots(extraSkillRoots);
408
414
  const nativeNames = new Set(entry.skills.map((skill) => skill.name));
@@ -411,10 +417,10 @@ export const createCodexProvider = async (extraSkillRoots = [], daemonLauncher =
411
417
  unavailableCount: entry.errors.length + roots.unavailableCount,
412
418
  observedAt: Date.now(),
413
419
  skills: [
414
- ...entry.skills.map((skill) => ({
420
+ ...entry.skills.map((skill, index) => ({
415
421
  name: skill.name,
416
422
  description: skill.description,
417
- argumentHint: null,
423
+ argumentHint: hints[index] ?? null,
418
424
  kind: 'skill',
419
425
  path: skill.path,
420
426
  scope: skill.scope,
@@ -430,7 +436,6 @@ export const createCodexProvider = async (extraSkillRoots = [], daemonLauncher =
430
436
  .filter((skill) => !nativeNames.has(skill.name))
431
437
  .map((skill) => ({
432
438
  ...skill,
433
- argumentHint: null,
434
439
  kind: 'skill',
435
440
  scope: HOST_SKILL_SCOPE,
436
441
  isEnabled: true,
@@ -3,6 +3,7 @@ export declare const MAX_LOADED_THREAD_PAGES = 8;
3
3
  export declare const TURN_TIMES_PAGE_SIZE = 128;
4
4
  export declare const MAX_TURN_TIME_PAGES = 8;
5
5
  export declare const RUNNING_TURNS_CAPACITY = 1024;
6
+ export declare const SKILL_HINT_READ_CONCURRENCY = 8;
6
7
  export declare const LOST_NOTIFICATIONS: Map<string, "unknown" | "turn-started" | "turn-completed" | "approval-resolved">;
7
8
  export declare const KNOWN_NATIVE_STATES: readonly ["notLoaded", "idle", "systemError", "active"];
8
9
  export declare const CODEX_FAST_SERVICE_TIER = "priority";
@@ -6,6 +6,8 @@ export const TURN_TIMES_PAGE_SIZE = 128;
6
6
  export const MAX_TURN_TIME_PAGES = 8;
7
7
  // the most threads whose running turn the live events keep
8
8
  export const RUNNING_TURNS_CAPACITY = 1024;
9
+ // the most skill files a catalog read reads at once for their argument hints
10
+ export const SKILL_HINT_READ_CONCURRENCY = 8;
9
11
  // the lifecycle notifications whose loss a live re-check of the session makes up for
10
12
  export const LOST_NOTIFICATIONS = new Map([
11
13
  ['turn/started', 'turn-started'],
@@ -1,4 +1,5 @@
1
1
  export declare const LOCAL_ENVIRONMENT_ID = "local";
2
2
  export declare const MAX_ROOT_SKILLS = 128;
3
3
  export declare const MAX_SKILL_FILE_BYTES = 65536;
4
+ export declare const MAX_ARGUMENT_HINT_LENGTH = 1024;
4
5
  export declare const HOST_SKILL_SCOPE = "host";
@@ -3,5 +3,7 @@ export const LOCAL_ENVIRONMENT_ID = 'local';
3
3
  // bounded inventory read from each operator-supplied root
4
4
  export const MAX_ROOT_SKILLS = 128;
5
5
  export const MAX_SKILL_FILE_BYTES = 65_536;
6
+ // the longest `argument-hint` a skill file can declare; a longer one reads as no hint
7
+ export const MAX_ARGUMENT_HINT_LENGTH = 1_024;
6
8
  // catalog scope for skills HQ adds from its extra roots, which native discovery doesn't list
7
9
  export const HOST_SKILL_SCOPE = 'host';
@@ -1,2 +1,3 @@
1
+ export type { IRootSkill, ISkillFrontmatter } from './types.js';
1
2
  export { HOST_SKILL_SCOPE } from './constants.js';
2
- export { parseSkillFrontmatter, readSkillRoots, toCapabilityRoots } from './skill-roots.js';
3
+ export { parseSkillFrontmatter, readSkillHint, readSkillRoots, toCapabilityRoots, } from './skill-roots.js';
@@ -1,4 +1,4 @@
1
1
  // constants
2
2
  export { HOST_SKILL_SCOPE } from './constants.js';
3
3
  // skill roots
4
- export { parseSkillFrontmatter, readSkillRoots, toCapabilityRoots } from './skill-roots.js';
4
+ export { parseSkillFrontmatter, readSkillHint, readSkillRoots, toCapabilityRoots, } from './skill-roots.js';
@@ -1,12 +1,11 @@
1
+ import type { IRootSkill, ISkillFrontmatter } from './types.js';
1
2
  /**
2
- * Reads a skill's single-line `name` and `description` frontmatter, the only fields HQ takes from
3
- * skill files.
4
- * @returns The skill identity, or null when the frontmatter is missing or not plain single-line.
3
+ * Reads a skill's single-line `name`, `description` and `argument-hint` frontmatter, the only
4
+ * fields HQ takes from skill files. A hint that is missing, empty, a block scalar or over
5
+ * MAX_ARGUMENT_HINT_LENGTH characters reads as null and never rejects the skill's identity.
6
+ * @returns The skill's frontmatter, or null when its identity is missing or not plain single-line.
5
7
  */
6
- export declare const parseSkillFrontmatter: (source: string) => {
7
- name: string;
8
- description: string;
9
- } | null;
8
+ export declare const parseSkillFrontmatter: (source: string) => ISkillFrontmatter | null;
10
9
  /**
11
10
  * Builds the per-thread capability roots Codex resolves for a thread HQ starts, so HQ's skills
12
11
  * never reach other sessions on the shared daemon.
@@ -20,16 +19,20 @@ export declare const toCapabilityRoots: (roots: string[]) => {
20
19
  path: string;
21
20
  };
22
21
  }[];
22
+ /**
23
+ * Reads the `argument-hint` of the skill file at an absolute path, such as one native discovery
24
+ * lists, as `readSkillRoots` reads its files. A file that can't be read leaves the skill without
25
+ * a hint, never without its listing.
26
+ * @returns A promise that resolves to the hint, or null when there is none or the file can't be
27
+ * read.
28
+ */
29
+ export declare const readSkillHint: (path: string) => Promise<string | null>;
23
30
  /**
24
31
  * Lists the skills in operator-supplied roots, one directory per skill holding a regular
25
32
  * `SKILL.md`. Linked directories and files are not followed.
26
33
  * @returns The readable skills and how many entries could not be read.
27
34
  */
28
35
  export declare const readSkillRoots: (roots: string[]) => Promise<{
29
- skills: {
30
- name: string;
31
- description: string;
32
- path: string;
33
- }[];
36
+ skills: IRootSkill[];
34
37
  unavailableCount: number;
35
38
  }>;
@@ -1,12 +1,13 @@
1
1
  import { constants } from 'node:fs';
2
2
  import { open, readdir } from 'node:fs/promises';
3
- import { join } from 'node:path';
3
+ import { isAbsolute, join } from 'node:path';
4
4
  import { hasErrorCode } from 'jg-exception';
5
- import { LOCAL_ENVIRONMENT_ID, MAX_ROOT_SKILLS, MAX_SKILL_FILE_BYTES } from './constants.js';
5
+ import { LOCAL_ENVIRONMENT_ID, MAX_ARGUMENT_HINT_LENGTH, MAX_ROOT_SKILLS, MAX_SKILL_FILE_BYTES, } from './constants.js';
6
6
  /**
7
- * Reads a skill's single-line `name` and `description` frontmatter, the only fields HQ takes from
8
- * skill files.
9
- * @returns The skill identity, or null when the frontmatter is missing or not plain single-line.
7
+ * Reads a skill's single-line `name`, `description` and `argument-hint` frontmatter, the only
8
+ * fields HQ takes from skill files. A hint that is missing, empty, a block scalar or over
9
+ * MAX_ARGUMENT_HINT_LENGTH characters reads as null and never rejects the skill's identity.
10
+ * @returns The skill's frontmatter, or null when its identity is missing or not plain single-line.
10
11
  */
11
12
  export const parseSkillFrontmatter = (source) => {
12
13
  const block = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(source)?.[1];
@@ -27,7 +28,9 @@ export const parseSkillFrontmatter = (source) => {
27
28
  description.length > 8192 ||
28
29
  /^[>|]/.test(description))
29
30
  return null;
30
- return { name, description };
31
+ const hint = read('argument-hint');
32
+ const argumentHint = !hint || hint.length > MAX_ARGUMENT_HINT_LENGTH || /^[>|]/.test(hint) ? null : hint;
33
+ return { name, description, argumentHint };
31
34
  };
32
35
  /**
33
36
  * Builds the per-thread capability roots Codex resolves for a thread HQ starts, so HQ's skills
@@ -38,6 +41,42 @@ export const toCapabilityRoots = (roots) => roots.map((path, index) => ({
38
41
  id: `jg-agent-hq-skills-${index}`,
39
42
  location: { type: 'environment', environmentId: LOCAL_ENVIRONMENT_ID, path },
40
43
  }));
44
+ /**
45
+ * Reads a skill file without following a link at its path: a regular file of at most
46
+ * MAX_SKILL_FILE_BYTES. The native error of opening or reading it, such as ENOENT when nothing is
47
+ * at the path, propagates for the caller to classify.
48
+ * @returns The file's text, or null when it is not a regular file or is too large.
49
+ */
50
+ const readSkillFile = async (path) => {
51
+ const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
52
+ try {
53
+ const stats = await handle.stat();
54
+ if (!stats.isFile() || stats.size > MAX_SKILL_FILE_BYTES)
55
+ return null;
56
+ return await handle.readFile('utf8');
57
+ }
58
+ finally {
59
+ await handle.close();
60
+ }
61
+ };
62
+ /**
63
+ * Reads the `argument-hint` of the skill file at an absolute path, such as one native discovery
64
+ * lists, as `readSkillRoots` reads its files. A file that can't be read leaves the skill without
65
+ * a hint, never without its listing.
66
+ * @returns A promise that resolves to the hint, or null when there is none or the file can't be
67
+ * read.
68
+ */
69
+ export const readSkillHint = async (path) => {
70
+ if (!isAbsolute(path))
71
+ return null;
72
+ try {
73
+ const source = await readSkillFile(path);
74
+ return source === null ? null : (parseSkillFrontmatter(source)?.argumentHint ?? null);
75
+ }
76
+ catch {
77
+ return null;
78
+ }
79
+ };
41
80
  /**
42
81
  * Lists the skills in operator-supplied roots, one directory per skill holding a regular
43
82
  * `SKILL.md`. Linked directories and files are not followed.
@@ -63,18 +102,7 @@ export const readSkillRoots = async (roots) => {
63
102
  const path = join(root, directory, 'SKILL.md');
64
103
  let source;
65
104
  try {
66
- const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
67
- try {
68
- const stats = await handle.stat();
69
- if (!stats.isFile() || stats.size > MAX_SKILL_FILE_BYTES) {
70
- unavailableCount += 1;
71
- continue;
72
- }
73
- source = await handle.readFile('utf8');
74
- }
75
- finally {
76
- await handle.close();
77
- }
105
+ source = await readSkillFile(path);
78
106
  }
79
107
  catch (error) {
80
108
  // a directory without SKILL.md is not a skill
@@ -82,7 +110,7 @@ export const readSkillRoots = async (roots) => {
82
110
  unavailableCount += 1;
83
111
  continue;
84
112
  }
85
- const parsed = parseSkillFrontmatter(source);
113
+ const parsed = source === null ? null : parseSkillFrontmatter(source);
86
114
  if (parsed)
87
115
  skills.push({ ...parsed, path });
88
116
  else
@@ -0,0 +1,8 @@
1
+ export type ISkillFrontmatter = {
2
+ name: string;
3
+ description: string;
4
+ argumentHint: string | null;
5
+ };
6
+ export type IRootSkill = ISkillFrontmatter & {
7
+ path: string;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jg-agent-hq",
3
- "version": "11.0.1",
3
+ "version": "11.1.0",
4
4
  "description": "Native Claude Code and Codex session control, history, usage and recoverable local storage for Node.js apps.",
5
5
  "type": "module",
6
6
  "license": "MIT",