@synap-core/cli 1.10.0 → 1.11.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.
Files changed (120) hide show
  1. package/dist/commands/capability.js +79 -8
  2. package/dist/commands/capability.js.map +1 -1
  3. package/dist/commands/centrality.js +2 -1
  4. package/dist/commands/centrality.js.map +1 -1
  5. package/dist/commands/context.js +2 -1
  6. package/dist/commands/context.js.map +1 -1
  7. package/dist/commands/data-extra.js +7 -4
  8. package/dist/commands/data-extra.js.map +1 -1
  9. package/dist/commands/data.js +14 -4
  10. package/dist/commands/data.js.map +1 -1
  11. package/dist/commands/diagnose.js +44 -1
  12. package/dist/commands/diagnose.js.map +1 -1
  13. package/dist/commands/digest.js +2 -1
  14. package/dist/commands/digest.js.map +1 -1
  15. package/dist/commands/doc.d.ts +14 -0
  16. package/dist/commands/doc.js +61 -4
  17. package/dist/commands/doc.js.map +1 -1
  18. package/dist/commands/doctor.d.ts +21 -0
  19. package/dist/commands/doctor.js +189 -0
  20. package/dist/commands/doctor.js.map +1 -0
  21. package/dist/commands/events.js +3 -1
  22. package/dist/commands/events.js.map +1 -1
  23. package/dist/commands/graph.js +5 -3
  24. package/dist/commands/graph.js.map +1 -1
  25. package/dist/commands/import.js +40 -9
  26. package/dist/commands/import.js.map +1 -1
  27. package/dist/commands/knowledge.d.ts +6 -0
  28. package/dist/commands/knowledge.js +253 -30
  29. package/dist/commands/knowledge.js.map +1 -1
  30. package/dist/commands/launch.js +2 -2
  31. package/dist/commands/launch.js.map +1 -1
  32. package/dist/commands/lens.js +1 -1
  33. package/dist/commands/lens.js.map +1 -1
  34. package/dist/commands/market-authoring.d.ts +45 -0
  35. package/dist/commands/market-authoring.js +225 -0
  36. package/dist/commands/market-authoring.js.map +1 -0
  37. package/dist/commands/market.d.ts +22 -7
  38. package/dist/commands/market.js +335 -60
  39. package/dist/commands/market.js.map +1 -1
  40. package/dist/commands/mcp.d.ts +24 -2
  41. package/dist/commands/mcp.js +84 -3
  42. package/dist/commands/mcp.js.map +1 -1
  43. package/dist/commands/pod.js +1 -1
  44. package/dist/commands/pod.js.map +1 -1
  45. package/dist/commands/pods.d.ts +14 -0
  46. package/dist/commands/pods.js +156 -2
  47. package/dist/commands/pods.js.map +1 -1
  48. package/dist/commands/proposals-actions.js +3 -0
  49. package/dist/commands/proposals-actions.js.map +1 -1
  50. package/dist/commands/sessions.js +2 -1
  51. package/dist/commands/sessions.js.map +1 -1
  52. package/dist/commands/skills.js +3 -1
  53. package/dist/commands/skills.js.map +1 -1
  54. package/dist/commands/template.d.ts +42 -0
  55. package/dist/commands/template.js +191 -0
  56. package/dist/commands/template.js.map +1 -0
  57. package/dist/commands/upload.d.ts +30 -0
  58. package/dist/commands/upload.js +155 -0
  59. package/dist/commands/upload.js.map +1 -0
  60. package/dist/index.js +118 -0
  61. package/dist/index.js.map +1 -1
  62. package/dist/lib/capture-lane.js +5 -3
  63. package/dist/lib/capture-lane.js.map +1 -1
  64. package/dist/lib/capture-structure.d.ts +123 -0
  65. package/dist/lib/capture-structure.js +57 -0
  66. package/dist/lib/capture-structure.js.map +1 -0
  67. package/dist/lib/cp-packages.d.ts +56 -0
  68. package/dist/lib/cp-packages.js +171 -0
  69. package/dist/lib/cp-packages.js.map +1 -1
  70. package/dist/lib/hub-client.d.ts +14 -1
  71. package/dist/lib/hub-client.js +110 -19
  72. package/dist/lib/hub-client.js.map +1 -1
  73. package/dist/lib/id.d.ts +23 -0
  74. package/dist/lib/id.js +35 -0
  75. package/dist/lib/id.js.map +1 -0
  76. package/dist/lib/pod.d.ts +53 -3
  77. package/dist/lib/pod.js +81 -9
  78. package/dist/lib/pod.js.map +1 -1
  79. package/dist/lib/template-file.d.ts +74 -0
  80. package/dist/lib/template-file.js +140 -0
  81. package/dist/lib/template-file.js.map +1 -0
  82. package/node_modules/@synap/hub-rest-client/dist/index.cjs +1261 -0
  83. package/node_modules/@synap/hub-rest-client/dist/index.d.cts +1647 -0
  84. package/node_modules/@synap/hub-rest-client/dist/index.d.ts +1647 -0
  85. package/node_modules/@synap/hub-rest-client/dist/index.js +1231 -0
  86. package/node_modules/@synap/hub-rest-client/package.json +45 -0
  87. package/node_modules/@synap/hub-rest-client/src/client.ts +1631 -0
  88. package/node_modules/@synap/hub-rest-client/src/errors.ts +30 -0
  89. package/node_modules/@synap/hub-rest-client/src/index.ts +153 -0
  90. package/node_modules/@synap/hub-rest-client/src/setup.ts +133 -0
  91. package/node_modules/@synap/hub-rest-client/src/types.ts +1299 -0
  92. package/package.json +3 -2
  93. package/skills/agent-os/SKILL.md +6 -0
  94. package/skills/manifest.json +1 -1
  95. package/skills/onboard/SKILL.md +7 -0
  96. package/skills/synap/SKILL.md +110 -29
  97. package/skills/synap/capture.md +50 -152
  98. package/skills/synap/common-mistakes.md +1 -0
  99. package/skills/synap/content-os.md +83 -0
  100. package/skills/synap/digesting-a-channel.md +25 -0
  101. package/skills/synap/mental-model.md +7 -7
  102. package/skills/synap/multi-entity-capture.md +6 -4
  103. package/skills/synap/worked-examples.md +21 -0
  104. package/skills/synap/writes.md +75 -18
  105. package/skills/synap-app/SKILL.md +319 -0
  106. package/skills/synap-app/_order.txt +5 -0
  107. package/skills/synap-app/_skill.yaml +20 -0
  108. package/skills/synap-app/creating-the-base-app.md +64 -0
  109. package/skills/synap-app/governance.md +42 -0
  110. package/skills/synap-app/install-commands.md +55 -0
  111. package/skills/synap-app/overview.md +50 -0
  112. package/skills/synap-app/using-the-sdk.md +73 -0
  113. package/skills/synap-market/SKILL.md +335 -0
  114. package/skills/synap-market/_order.txt +5 -0
  115. package/skills/synap-market/_skill.yaml +24 -0
  116. package/skills/synap-market/author-and-publish.md +75 -0
  117. package/skills/synap-market/discover-and-fetch.md +59 -0
  118. package/skills/synap-market/governance-and-catalog.md +56 -0
  119. package/skills/synap-market/install.md +55 -0
  120. package/skills/synap-market/overview.md +51 -0
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Hub Protocol REST API error class.
3
+ * Thrown when the server returns a non-2xx response.
4
+ */
5
+ export class HubApiError extends Error {
6
+ constructor(
7
+ message: string,
8
+ public readonly statusCode: number,
9
+ public readonly body?: unknown
10
+ ) {
11
+ super(message);
12
+ this.name = "HubApiError";
13
+ }
14
+
15
+ get isUnauthorized(): boolean {
16
+ return this.statusCode === 401;
17
+ }
18
+
19
+ get isForbidden(): boolean {
20
+ return this.statusCode === 403;
21
+ }
22
+
23
+ get isNotFound(): boolean {
24
+ return this.statusCode === 404;
25
+ }
26
+
27
+ get isServerError(): boolean {
28
+ return this.statusCode >= 500;
29
+ }
30
+ }
@@ -0,0 +1,153 @@
1
+ /**
2
+ * @synap/hub-rest-client
3
+ *
4
+ * Zero-dependency TypeScript client for the Synap Hub Protocol REST API.
5
+ *
6
+ * Works in Node.js >= 18, browsers, Deno, Bun, and Raycast extensions.
7
+ *
8
+ * @example Basic usage
9
+ * ```ts
10
+ * import { HubRestClient } from "@synap/hub-rest-client";
11
+ *
12
+ * const client = new HubRestClient({
13
+ * podUrl: "https://my-pod.synap.live",
14
+ * apiKey: process.env.SYNAP_HUB_API_KEY!,
15
+ * });
16
+ *
17
+ * const entities = await client.searchEntities("meeting notes");
18
+ * const task = await client.createEntity({ profileSlug: "task", title: "Fix bug" });
19
+ * ```
20
+ *
21
+ * @example Setup flow (new agent)
22
+ * ```ts
23
+ * import { setupAgent, checkPodHealth } from "@synap/hub-rest-client";
24
+ *
25
+ * const status = await checkPodHealth("https://my-pod.synap.live");
26
+ * if (status.healthy) {
27
+ * const { hubApiKey, workspaceId } = await setupAgent(
28
+ * "https://my-pod.synap.live",
29
+ * process.env.PROVISIONING_TOKEN!,
30
+ * "my-agent"
31
+ * );
32
+ * }
33
+ * ```
34
+ */
35
+
36
+ // Client
37
+ export { HubRestClient } from "./client.js";
38
+ export type { HubRestClientConfig } from "./client.js";
39
+
40
+ // Errors
41
+ export { HubApiError } from "./errors.js";
42
+
43
+ // Setup utilities
44
+ export { checkPodHealth, setupAgent } from "./setup.js";
45
+
46
+ // Types
47
+ export type {
48
+ // Core entity types
49
+ HubEntity,
50
+ HubDocument,
51
+ HubDocumentChange,
52
+ HubDocumentProposalResult,
53
+ HubChannel,
54
+ HubWorkspace,
55
+ HubWorkspacesListResponse,
56
+ HubUser,
57
+ HubMemoryResult,
58
+ HubListResponse,
59
+ HubSingleResponse,
60
+ // Relations & Graph
61
+ HubRelation,
62
+ HubGraphNode,
63
+ HubGraphEdge,
64
+ HubGraphResult,
65
+ HubConnection,
66
+ HubConnectionsResult,
67
+ // Profiles & Schema
68
+ HubProfile,
69
+ HubPropertyDef,
70
+ HubDiscoverResult,
71
+ HubDiscoverProfile,
72
+ HubDiscoverProperty,
73
+ HubDiscoverOptions,
74
+ HubOrientScope,
75
+ HubOrientDetail,
76
+ HubOrientProfile,
77
+ HubOrientWorkspace,
78
+ HubOrientProject,
79
+ HubOrientTeamRoster,
80
+ HubOrientResult,
81
+ HubOrientOptions,
82
+ // Threads & Channels
83
+ HubThread,
84
+ HubMessage,
85
+ HubThreadContext,
86
+ // Proposals
87
+ HubProposal,
88
+ // Views
89
+ HubView,
90
+ HubBentoArrangementResult,
91
+ // Search
92
+ HubSearchResult,
93
+ // Commands & Agents
94
+ HubCommand,
95
+ HubAgentUser,
96
+ // User Context
97
+ HubUserContext,
98
+ // Governance
99
+ HubGovernanceResult,
100
+ HubAttachFacetResult,
101
+ HubWriteReceipt,
102
+ HubWriteSource,
103
+ // Capabilities & teaching substrate
104
+ HubCapabilityVerb,
105
+ HubCapability,
106
+ HubCapabilityCatalogConnection,
107
+ HubCapabilityCatalogCard,
108
+ HubCapabilityCatalogResult,
109
+ HubRunnableCapabilityAction,
110
+ HubRunnableCapabilityActionsResult,
111
+ ExecuteCapabilityResult,
112
+ HubAgentSkill,
113
+ ListAgentSkillsOptions,
114
+ HubAgentSkillsResult,
115
+ GetCapabilityBriefsInput,
116
+ HubCapabilityBriefsResult,
117
+ // Input types — Entity
118
+ CreateEntityInput,
119
+ UpdateEntityInput,
120
+ // Input types — Documents
121
+ CreateDocumentInput,
122
+ UpdateDocumentInput,
123
+ CreateDocumentProposalInput,
124
+ // Input types — Memory
125
+ StoreMemoryInput,
126
+ // Input types — Channels
127
+ SendToChannelInput,
128
+ // Input types — Relations, Threads, Views, Commands
129
+ CreateRelationInput,
130
+ CreateThreadInput,
131
+ CreateViewInput,
132
+ UpdateViewInput,
133
+ BentoWidgetInput,
134
+ ArrangeBentoViewInput,
135
+ ExecuteCommandInput,
136
+ // Setup
137
+ AgentSetupResult,
138
+ PodStatus,
139
+ // Capture pipeline
140
+ CaptureProposal,
141
+ CaptureRelation,
142
+ CaptureStructureResponse,
143
+ CaptureExecuteInput,
144
+ CaptureExecuteResponse,
145
+ CaptureGraphEntity,
146
+ CaptureGraphRelation,
147
+ CaptureGraphBinding,
148
+ CaptureGraphRawSource,
149
+ SubmitCaptureGraphInput,
150
+ SubmitCaptureGraphResult,
151
+ AskResponse,
152
+ AskAnswerBlock,
153
+ } from "./types.js";
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Pod setup and health utilities.
3
+ *
4
+ * These functions are the canonical implementations shared between
5
+ * the Synap CLI and the Raycast extension. They use the native fetch API
6
+ * and have zero Node.js-specific dependencies.
7
+ *
8
+ * ⚠️ `assertValidPodUrl` below is a DUPLICATE of the guard in
9
+ * `@synap-core/auth-bootstrap` (`src/url.ts`). It is copied, not imported,
10
+ * because this package is deliberately zero-dependency. The two copies must
11
+ * be kept in sync — change one, change the other.
12
+ */
13
+
14
+ import { HubApiError } from "./errors.js";
15
+ import type { AgentSetupResult, PodStatus } from "./types.js";
16
+
17
+ function normalizeUrl(url: string): string {
18
+ return url.replace(/\/$/, "");
19
+ }
20
+
21
+ /** Shared per-request knobs for the credential-bearing bootstrap calls. */
22
+ export interface BootstrapRequestOptions {
23
+ /** Allow `http://` pod URLs (localhost / local-mode dev only). */
24
+ allowHttp?: boolean;
25
+ }
26
+
27
+ /**
28
+ * Throws `HubApiError(status:0)` if `url` is not a valid http(s) pod origin:
29
+ * must parse, be `https:` (or `http:` when `allowHttp`), and carry no embedded
30
+ * credentials.
31
+ *
32
+ * `podUrl` is attacker-influenceable in multi-tenant / portal contexts, and the
33
+ * bootstrap helpers POST bearer tokens to it — so every credential-bearing call
34
+ * validates the URL first. Without this a caller could be coaxed into sending an
35
+ * issuer assertion or provisioning token to an arbitrary host.
36
+ *
37
+ * Kept in sync with `@synap-core/auth-bootstrap`'s `assertValidPodUrl`.
38
+ */
39
+ function assertValidPodUrl(
40
+ url: string,
41
+ opts: BootstrapRequestOptions = {}
42
+ ): void {
43
+ let parsed: URL;
44
+ try {
45
+ parsed = new URL(url);
46
+ } catch {
47
+ throw new HubApiError(`Invalid pod URL: ${url}`, 0, {
48
+ code: "INVALID_POD_URL",
49
+ });
50
+ }
51
+ if (parsed.username || parsed.password) {
52
+ throw new HubApiError("Pod URL must not contain embedded credentials", 0, {
53
+ code: "INVALID_POD_URL",
54
+ });
55
+ }
56
+ const isHttps = parsed.protocol === "https:";
57
+ const isHttp = parsed.protocol === "http:";
58
+ if (!isHttps && !(isHttp && opts.allowHttp)) {
59
+ throw new HubApiError(
60
+ `Pod URL must use https:// (got ${parsed.protocol}//)`,
61
+ 0,
62
+ { code: "INSECURE_POD_URL" }
63
+ );
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Check whether a Synap pod is healthy.
69
+ * Hits `GET {podUrl}/health` with a 5s timeout.
70
+ */
71
+ export async function checkPodHealth(podUrl: string): Promise<PodStatus> {
72
+ const url = normalizeUrl(podUrl);
73
+ const status: PodStatus = { url, healthy: false };
74
+
75
+ try {
76
+ const res = await fetch(`${url}/health`, {
77
+ signal: AbortSignal.timeout(5000),
78
+ });
79
+ if (res.ok) {
80
+ status.healthy = true;
81
+ const data = (await res.json()) as Record<string, unknown>;
82
+ status.version = data.version as string | undefined;
83
+ }
84
+ } catch {
85
+ // pod unreachable or timed out
86
+ }
87
+
88
+ return status;
89
+ }
90
+
91
+ /**
92
+ * Create an agent user + Hub Protocol API key on the pod.
93
+ *
94
+ * Auth: `Authorization: Bearer <provisioningToken>`
95
+ * The provisioning token is either:
96
+ * - The pod's `PROVISIONING_TOKEN` env var (self-hosted path)
97
+ * - A CP-signed `agent_setup` JWT (managed pod path)
98
+ *
99
+ * Endpoint: `POST {podUrl}/api/hub/setup/agent`
100
+ */
101
+ export async function setupAgent(
102
+ podUrl: string,
103
+ provisioningToken: string,
104
+ // REQUIRED (was defaulted to "openclaw"). See auth-bootstrap/setup.ts — the
105
+ // default silently minted bare callers onto the pod-wide `openclaw` singleton
106
+ // (0037); required makes any omitter a compile error, never a silent shift.
107
+ agentType: string,
108
+ opts: BootstrapRequestOptions = {}
109
+ ): Promise<AgentSetupResult> {
110
+ assertValidPodUrl(podUrl, { allowHttp: opts.allowHttp });
111
+ const url = normalizeUrl(podUrl);
112
+
113
+ const res = await fetch(`${url}/api/hub/setup/agent`, {
114
+ method: "POST",
115
+ headers: {
116
+ "Content-Type": "application/json",
117
+ Authorization: `Bearer ${provisioningToken}`,
118
+ },
119
+ body: JSON.stringify({ agentType }),
120
+ signal: AbortSignal.timeout(15_000),
121
+ });
122
+
123
+ if (!res.ok) {
124
+ const body = await res.json().catch(() => ({}));
125
+ throw new HubApiError(
126
+ `Agent setup failed (HTTP ${res.status})`,
127
+ res.status,
128
+ body
129
+ );
130
+ }
131
+
132
+ return res.json() as Promise<AgentSetupResult>;
133
+ }