@synap-core/workspace-templates 0.72.0 → 0.74.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/src/validate.ts CHANGED
@@ -1459,6 +1459,49 @@ function checkPresentationDeclarations(
1459
1459
  }
1460
1460
  }
1461
1461
 
1462
+ // ── Server-derived properties: the pod writes them, a template only declares ─
1463
+
1464
+ /**
1465
+ * Property keys the POD derives and writes on any kind a session takes as its
1466
+ * subject (backend#1449, migration 0468): mirrors
1467
+ * `SERVER_DERIVED_PROPERTY_KEYS` in synap-backend
1468
+ * `packages/database/src/utils/worked-in.ts`, pinned equal by
1469
+ * `builder-work-views.template.test.ts`. A template may DECLARE them (a saved
1470
+ * view filters only on a declared property) but never give them a value: the
1471
+ * pod's triggers strip them from any other write, so a default or an option
1472
+ * list would be a promise the pod refuses (rule `property-server-derived-value`).
1473
+ */
1474
+ export const SERVER_DERIVED_PROPERTY_KEYS: readonly string[] = ["workedIn", "workedInAll"];
1475
+
1476
+ /**
1477
+ * The server-derived keys that hold ONE string, so a kanban can group by them:
1478
+ * one column per distinct value (`KanbanAdapter` derives columns from the
1479
+ * values entities carry when the field has no option list).
1480
+ */
1481
+ export const SERVER_DERIVED_GROUP_KEYS: readonly string[] = ["workedIn"];
1482
+
1483
+ function checkServerDerivedProperties(
1484
+ tpl: WorkspaceYaml,
1485
+ add: (rule: string, path: string, message: string) => void
1486
+ ): void {
1487
+ for (const p of tpl.profiles || [])
1488
+ for (const pr of p.properties || []) {
1489
+ if (!SERVER_DERIVED_PROPERTY_KEYS.includes(pr.slug)) continue;
1490
+ const c = (pr.constraints ?? {}) as Record<string, unknown>;
1491
+ const valued = [
1492
+ ...(Array.isArray(pr.enumValues) && pr.enumValues.length > 0 ? ["enumValues"] : []),
1493
+ ...("defaultValue" in c ? ["constraints.defaultValue"] : []),
1494
+ ...("enum" in c ? ["constraints.enum"] : []),
1495
+ ];
1496
+ if (valued.length > 0)
1497
+ add(
1498
+ "property-server-derived-value",
1499
+ `profiles.${p.slug}.${pr.slug}`,
1500
+ `property ${p.slug}.${pr.slug} is written by the pod alone; a template declares it and gives it no value (${valued.join(", ")})`
1501
+ );
1502
+ }
1503
+ }
1504
+
1462
1505
  // ── Kanban grouping: the board names the field its columns are ─────────────
1463
1506
 
1464
1507
  /**
@@ -1472,7 +1515,9 @@ function checkPresentationDeclarations(
1472
1515
  * by `status`;
1473
1516
  * - `config.groupByField` is required;
1474
1517
  * - it names a select property (with enumValues) of the scoped kind, when a
1475
- * declaration of that kind is in reach (a system kind is not judged).
1518
+ * declaration of that kind is in reach (a system kind is not judged), or a
1519
+ * string property of that kind the pod derives ({@link SERVER_DERIVED_GROUP_KEYS}:
1520
+ * one column per distinct value, no option list exists to name).
1476
1521
  */
1477
1522
  function checkKanbanGrouping(
1478
1523
  tpl: WorkspaceYaml,
@@ -1513,11 +1558,16 @@ function checkKanbanGrouping(
1513
1558
  const prop = decls
1514
1559
  .flatMap((p) => p.properties ?? [])
1515
1560
  .find((p) => p.slug === slug);
1561
+ const derivedGroup =
1562
+ !!prop &&
1563
+ SERVER_DERIVED_GROUP_KEYS.includes(prop.slug) &&
1564
+ prop.valueType === "string";
1516
1565
  if (
1517
- !prop ||
1518
- prop.inputType !== "select" ||
1519
- !Array.isArray(prop.enumValues) ||
1520
- prop.enumValues.length === 0
1566
+ !derivedGroup &&
1567
+ (!prop ||
1568
+ prop.inputType !== "select" ||
1569
+ !Array.isArray(prop.enumValues) ||
1570
+ prop.enumValues.length === 0)
1521
1571
  )
1522
1572
  add(
1523
1573
  "view-kanban-group-unknown",
@@ -2736,6 +2786,7 @@ export function validateTemplate(
2736
2786
  checkStageDomains(tpl, resolveDepFrom(opts), add);
2737
2787
  checkProcessContract(tpl, resolveDepFrom(opts), opts.corpus, add);
2738
2788
  checkKanbanGrouping(tpl, resolveDepFrom(opts), opts.corpus, add);
2789
+ checkServerDerivedProperties(tpl, add);
2739
2790
  checkLifecycleDeclarations(tpl, resolveDepFrom(opts), opts.corpus, add);
2740
2791
  checkPresentationDeclarations(tpl, resolveDepFrom(opts), opts.corpus, add);
2741
2792
  checkIntent(tpl, resolveDepFrom(opts), add);
@@ -1,176 +0,0 @@
1
- {
2
- "apiVersion": "synap/v1",
3
- "kind": "capability",
4
- "meta": {
5
- "slug": "github-issues",
6
- "name": "GitHub Issues",
7
- "description": "GitHub Issues capability",
8
- "tags": [
9
- "capability"
10
- ],
11
- "isPublic": true,
12
- "syncByDefault": true
13
- },
14
- "spec": {
15
- "key": "github-issues",
16
- "name": "GitHub Issues",
17
- "description": "GitHub Issues capability",
18
- "params": [
19
- {
20
- "name": "github-issuesApiKey",
21
- "label": "GitHub Issues API Key",
22
- "type": "text",
23
- "required": true,
24
- "description": "The GitHub Issues API key. Stored server-encrypted in the vault; never persisted in the template.",
25
- "obtain": {
26
- "url": "https://example.com/dashboard/keys",
27
- "steps": [
28
- "Obtain your API key from the provider dashboard",
29
- "Copy and paste it here"
30
- ]
31
- }
32
- }
33
- ],
34
- "vault": [
35
- {
36
- "ref": "apiKeySecret",
37
- "name": "{{name}} API key",
38
- "value": "{{github-issuesApiKey}}",
39
- "type": "api_key",
40
- "description": "API key for the GitHub Issues connector."
41
- }
42
- ],
43
- "tools": [
44
- {
45
- "name": "github-issues_api",
46
- "kind": "api",
47
- "description": "Authenticated HTTP access to the GitHub Issues API.",
48
- "credentialRef": "apiKeySecret",
49
- "executor": "is-agent",
50
- "config": {
51
- "baseUrl": "https://api.github.com",
52
- "auth": {
53
- "in": "header",
54
- "name": "Authorization",
55
- "prefix": "Bearer "
56
- }
57
- }
58
- }
59
- ],
60
- "skills": [
61
- {
62
- "name": "github-issues_search",
63
- "kind": "code",
64
- "scope": "pod",
65
- "requires": [
66
- "github-issues_api"
67
- ],
68
- "executionMode": "async",
69
- "timeoutSeconds": 60,
70
- "intent": "search_external",
71
- "description": "Search searchs via the GithubIssues API and propose results as github-issues entities.",
72
- "parameters": {
73
- "query": "string",
74
- "limit": "number?",
75
- "page": "number?"
76
- },
77
- "code": "// Search skill — calls the API and proposes results as github-issues entities\nconst query = String(args?.query ?? '').trim();\nif (!query) throw new Error('query is required');\n\nconst limit = args?.limit ? Math.min(Number(args.limit), 100) : 20;\nconst page = args?.page ? Math.max(Number(args.page), 1) : 1;\nconst path = args?.path || '/search';\n\nconst payload = { q: query, per_page: limit, page };\n\nconst res = await callProvider('github-issues_api', 'GET', path, payload);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\nconst items = Array.isArray(body) ? body : (body?.items ?? body?.data ?? body?.results ?? []);\n\nif (!ok || items.length === 0) {\n return { success: false, message: 'No results found' };\n}\n\nconst proposed = [];\nfor (const item of items) {\n const r = await propose.entity({\n profileSlug: 'github-issues',\n title: String(item?.title ?? item?.name ?? item?.id ?? 'result'),\n properties: { ...item, externalId: String(item?.id ?? item?.externalId ?? '') },\n });\n proposed.push(r);\n}\n\nreturn { success: true, count: items.length, proposed };"
78
- },
79
- {
80
- "name": "github-issues_create",
81
- "kind": "code",
82
- "scope": "pod",
83
- "requires": [
84
- "github-issues_api"
85
- ],
86
- "executionMode": "async",
87
- "timeoutSeconds": 60,
88
- "intent": "capture_into_pod",
89
- "description": "Create a new create via the GithubIssues API and propose it as a github-issues entity.",
90
- "parameters": {
91
- "title": "string",
92
- "properties": "object?",
93
- "externalId": "string?"
94
- },
95
- "code": "// Create skill — POST to API and propose the created entity\nconst title = String(args?.title ?? '').trim();\nif (!title) throw new Error('title is required');\n\nconst path = args?.path || '/create';\nconst payload = { ...args };\ndelete payload.path;\ndelete payload.title;\n\nconst res = await callProvider('github-issues_api', 'POST', path, payload);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\n\nif (!ok) {\n throw new Error(`create failed (${res?.status ?? 'unknown'})`);\n}\n\nconst r = await propose.entity({\n profileSlug: 'github-issues',\n title,\n properties: { ...body, externalId: String(body?.id ?? body?.externalId ?? '') },\n});\n\nreturn { success: true, proposed: r };"
96
- },
97
- {
98
- "name": "github-issues_update",
99
- "kind": "code",
100
- "scope": "pod",
101
- "requires": [
102
- "github-issues_api"
103
- ],
104
- "executionMode": "async",
105
- "timeoutSeconds": 60,
106
- "intent": "manage_file",
107
- "description": "Update an existing update via the GithubIssues API.",
108
- "parameters": {
109
- "externalId": "string",
110
- "title": "string?",
111
- "properties": "object?",
112
- "status": "string?"
113
- },
114
- "code": "// Update skill — PATCH/PUT to API\nconst externalId = String(args?.externalId ?? '').trim();\nif (!externalId) throw new Error('externalId is required');\n\nconst path = args?.path || `/${externalId}`;\nconst payload = { ...args };\ndelete payload.path;\ndelete payload.externalId;\n\nconst res = await callProvider('github-issues_api', 'PATCH', path, payload);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\n\nif (!ok) {\n throw new Error(`update failed (${res?.status ?? 'unknown'})`);\n}\n\nconst r = await propose.entity({\n profileSlug: 'github-issues',\n title: String(body?.title ?? body?.name ?? externalId),\n properties: { ...body, externalId },\n});\n\nreturn { success: true, proposed: r };"
115
- },
116
- {
117
- "name": "github-issues_delete",
118
- "kind": "code",
119
- "scope": "pod",
120
- "requires": [
121
- "github-issues_api"
122
- ],
123
- "executionMode": "async",
124
- "timeoutSeconds": 60,
125
- "intent": "manage_file",
126
- "description": "Delete a delete via the GithubIssues API.",
127
- "parameters": {
128
- "externalId": "string"
129
- },
130
- "code": "// Delete skill — DELETE from API\nconst externalId = String(args?.externalId ?? '').trim();\nif (!externalId) throw new Error('externalId is required');\n\nconst path = args?.path || `/${externalId}`;\n\nconst res = await callProvider('github-issues_api', 'DELETE', path);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\n\nif (!ok) {\n throw new Error(`delete failed (${res?.status ?? 'unknown'})`);\n}\n\nreturn { success: true, deleted: externalId };"
131
- },
132
- {
133
- "name": "github-issues_list",
134
- "kind": "code",
135
- "scope": "pod",
136
- "requires": [
137
- "github-issues_api"
138
- ],
139
- "executionMode": "async",
140
- "timeoutSeconds": 60,
141
- "intent": "list_records",
142
- "description": "List lists via the GithubIssues API.",
143
- "parameters": {
144
- "limit": "number?",
145
- "page": "number?",
146
- "status": "string?"
147
- },
148
- "code": "// List skill — GET list from API\nconst limit = args?.limit ? Math.min(Number(args.limit), 100) : 20;\nconst page = args?.page ? Math.max(Number(args.page), 1) : 1;\nconst status = args?.status ? String(args.status).trim() : '';\nconst path = args?.path || '/list';\n\nconst payload = { per_page: limit, page };\nif (status) payload.status = status;\n\nconst res = await callProvider('github-issues_api', 'GET', path, payload);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\nconst items = Array.isArray(body) ? body : (body?.items ?? body?.data ?? body?.results ?? []);\n\nif (!ok) {\n return { success: false, message: 'List request failed' };\n}\n\nreturn { success: true, count: items.length, items };"
149
- },
150
- {
151
- "name": "github-issues_get",
152
- "kind": "code",
153
- "scope": "pod",
154
- "requires": [
155
- "github-issues_api"
156
- ],
157
- "executionMode": "async",
158
- "timeoutSeconds": 60,
159
- "intent": "fetch_record",
160
- "description": "Get a single get by external ID via the GithubIssues API.",
161
- "parameters": {
162
- "externalId": "string"
163
- },
164
- "code": "// Get skill — GET single entity by external ID\nconst externalId = String(args?.externalId ?? '').trim();\nif (!externalId) throw new Error('externalId is required');\n\nconst path = args?.path || `/${externalId}`;\n\nconst res = await callProvider('github-issues_api', 'GET', path);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\n\nif (!ok || !body) {\n return { success: false, message: 'Not found' };\n}\n\nconst r = await propose.entity({\n profileSlug: 'github-issues',\n title: String(body?.title ?? body?.name ?? externalId),\n properties: { ...body, externalId },\n});\n\nreturn { success: true, proposed: r };"
165
- }
166
- ],
167
- "provides": [
168
- "search_external",
169
- "capture_into_pod",
170
- "manage_file",
171
- "list_records",
172
- "fetch_record"
173
- ]
174
- },
175
- "dependencies": []
176
- }
@@ -1,176 +0,0 @@
1
- {
2
- "apiVersion": "synap/v1",
3
- "kind": "capability",
4
- "meta": {
5
- "slug": "stripe-payments",
6
- "name": "Stripe Payments",
7
- "description": "Stripe Payments capability",
8
- "tags": [
9
- "capability"
10
- ],
11
- "isPublic": true,
12
- "syncByDefault": true
13
- },
14
- "spec": {
15
- "key": "stripe-payments",
16
- "name": "Stripe Payments",
17
- "description": "Stripe Payments capability",
18
- "params": [
19
- {
20
- "name": "stripe-paymentsApiKey",
21
- "label": "Stripe Payments API Key",
22
- "type": "text",
23
- "required": true,
24
- "description": "The Stripe Payments API key. Stored server-encrypted in the vault; never persisted in the template.",
25
- "obtain": {
26
- "url": "https://example.com/dashboard/keys",
27
- "steps": [
28
- "Obtain your API key from the provider dashboard",
29
- "Copy and paste it here"
30
- ]
31
- }
32
- }
33
- ],
34
- "vault": [
35
- {
36
- "ref": "apiKeySecret",
37
- "name": "{{name}} API key",
38
- "value": "{{stripe-paymentsApiKey}}",
39
- "type": "api_key",
40
- "description": "API key for the Stripe Payments connector."
41
- }
42
- ],
43
- "tools": [
44
- {
45
- "name": "stripe-payments_api",
46
- "kind": "api",
47
- "description": "Authenticated HTTP access to the Stripe Payments API.",
48
- "credentialRef": "apiKeySecret",
49
- "executor": "is-agent",
50
- "config": {
51
- "baseUrl": "https://api.stripe.com/v1",
52
- "auth": {
53
- "in": "header",
54
- "name": "Authorization",
55
- "prefix": "Bearer "
56
- }
57
- }
58
- }
59
- ],
60
- "skills": [
61
- {
62
- "name": "stripe-payments_search",
63
- "kind": "code",
64
- "scope": "pod",
65
- "requires": [
66
- "stripe-payments_api"
67
- ],
68
- "executionMode": "async",
69
- "timeoutSeconds": 60,
70
- "intent": "search_external",
71
- "description": "Search searchs via the StripePayments API and propose results as stripe-payments entities.",
72
- "parameters": {
73
- "query": "string",
74
- "limit": "number?",
75
- "page": "number?"
76
- },
77
- "code": "// Search skill — calls the API and proposes results as stripe-payments entities\nconst query = String(args?.query ?? '').trim();\nif (!query) throw new Error('query is required');\n\nconst limit = args?.limit ? Math.min(Number(args.limit), 100) : 20;\nconst page = args?.page ? Math.max(Number(args.page), 1) : 1;\nconst path = args?.path || '/search';\n\nconst payload = { q: query, per_page: limit, page };\n\nconst res = await callProvider('stripe-payments_api', 'GET', path, payload);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\nconst items = Array.isArray(body) ? body : (body?.items ?? body?.data ?? body?.results ?? []);\n\nif (!ok || items.length === 0) {\n return { success: false, message: 'No results found' };\n}\n\nconst proposed = [];\nfor (const item of items) {\n const r = await propose.entity({\n profileSlug: 'stripe-payments',\n title: String(item?.title ?? item?.name ?? item?.id ?? 'result'),\n properties: { ...item, externalId: String(item?.id ?? item?.externalId ?? '') },\n });\n proposed.push(r);\n}\n\nreturn { success: true, count: items.length, proposed };"
78
- },
79
- {
80
- "name": "stripe-payments_create",
81
- "kind": "code",
82
- "scope": "pod",
83
- "requires": [
84
- "stripe-payments_api"
85
- ],
86
- "executionMode": "async",
87
- "timeoutSeconds": 60,
88
- "intent": "capture_into_pod",
89
- "description": "Create a new create via the StripePayments API and propose it as a stripe-payments entity.",
90
- "parameters": {
91
- "title": "string",
92
- "properties": "object?",
93
- "externalId": "string?"
94
- },
95
- "code": "// Create skill — POST to API and propose the created entity\nconst title = String(args?.title ?? '').trim();\nif (!title) throw new Error('title is required');\n\nconst path = args?.path || '/create';\nconst payload = { ...args };\ndelete payload.path;\ndelete payload.title;\n\nconst res = await callProvider('stripe-payments_api', 'POST', path, payload);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\n\nif (!ok) {\n throw new Error(`create failed (${res?.status ?? 'unknown'})`);\n}\n\nconst r = await propose.entity({\n profileSlug: 'stripe-payments',\n title,\n properties: { ...body, externalId: String(body?.id ?? body?.externalId ?? '') },\n});\n\nreturn { success: true, proposed: r };"
96
- },
97
- {
98
- "name": "stripe-payments_update",
99
- "kind": "code",
100
- "scope": "pod",
101
- "requires": [
102
- "stripe-payments_api"
103
- ],
104
- "executionMode": "async",
105
- "timeoutSeconds": 60,
106
- "intent": "manage_file",
107
- "description": "Update an existing update via the StripePayments API.",
108
- "parameters": {
109
- "externalId": "string",
110
- "title": "string?",
111
- "properties": "object?",
112
- "status": "string?"
113
- },
114
- "code": "// Update skill — PATCH/PUT to API\nconst externalId = String(args?.externalId ?? '').trim();\nif (!externalId) throw new Error('externalId is required');\n\nconst path = args?.path || `/${externalId}`;\nconst payload = { ...args };\ndelete payload.path;\ndelete payload.externalId;\n\nconst res = await callProvider('stripe-payments_api', 'PATCH', path, payload);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\n\nif (!ok) {\n throw new Error(`update failed (${res?.status ?? 'unknown'})`);\n}\n\nconst r = await propose.entity({\n profileSlug: 'stripe-payments',\n title: String(body?.title ?? body?.name ?? externalId),\n properties: { ...body, externalId },\n});\n\nreturn { success: true, proposed: r };"
115
- },
116
- {
117
- "name": "stripe-payments_delete",
118
- "kind": "code",
119
- "scope": "pod",
120
- "requires": [
121
- "stripe-payments_api"
122
- ],
123
- "executionMode": "async",
124
- "timeoutSeconds": 60,
125
- "intent": "manage_file",
126
- "description": "Delete a delete via the StripePayments API.",
127
- "parameters": {
128
- "externalId": "string"
129
- },
130
- "code": "// Delete skill — DELETE from API\nconst externalId = String(args?.externalId ?? '').trim();\nif (!externalId) throw new Error('externalId is required');\n\nconst path = args?.path || `/${externalId}`;\n\nconst res = await callProvider('stripe-payments_api', 'DELETE', path);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\n\nif (!ok) {\n throw new Error(`delete failed (${res?.status ?? 'unknown'})`);\n}\n\nreturn { success: true, deleted: externalId };"
131
- },
132
- {
133
- "name": "stripe-payments_list",
134
- "kind": "code",
135
- "scope": "pod",
136
- "requires": [
137
- "stripe-payments_api"
138
- ],
139
- "executionMode": "async",
140
- "timeoutSeconds": 60,
141
- "intent": "list_records",
142
- "description": "List lists via the StripePayments API.",
143
- "parameters": {
144
- "limit": "number?",
145
- "page": "number?",
146
- "status": "string?"
147
- },
148
- "code": "// List skill — GET list from API\nconst limit = args?.limit ? Math.min(Number(args.limit), 100) : 20;\nconst page = args?.page ? Math.max(Number(args.page), 1) : 1;\nconst status = args?.status ? String(args.status).trim() : '';\nconst path = args?.path || '/list';\n\nconst payload = { per_page: limit, page };\nif (status) payload.status = status;\n\nconst res = await callProvider('stripe-payments_api', 'GET', path, payload);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\nconst items = Array.isArray(body) ? body : (body?.items ?? body?.data ?? body?.results ?? []);\n\nif (!ok) {\n return { success: false, message: 'List request failed' };\n}\n\nreturn { success: true, count: items.length, items };"
149
- },
150
- {
151
- "name": "stripe-payments_get",
152
- "kind": "code",
153
- "scope": "pod",
154
- "requires": [
155
- "stripe-payments_api"
156
- ],
157
- "executionMode": "async",
158
- "timeoutSeconds": 60,
159
- "intent": "fetch_record",
160
- "description": "Get a single get by external ID via the StripePayments API.",
161
- "parameters": {
162
- "externalId": "string"
163
- },
164
- "code": "// Get skill — GET single entity by external ID\nconst externalId = String(args?.externalId ?? '').trim();\nif (!externalId) throw new Error('externalId is required');\n\nconst path = args?.path || `/${externalId}`;\n\nconst res = await callProvider('stripe-payments_api', 'GET', path);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\n\nif (!ok || !body) {\n return { success: false, message: 'Not found' };\n}\n\nconst r = await propose.entity({\n profileSlug: 'stripe-payments',\n title: String(body?.title ?? body?.name ?? externalId),\n properties: { ...body, externalId },\n});\n\nreturn { success: true, proposed: r };"
165
- }
166
- ],
167
- "provides": [
168
- "search_external",
169
- "capture_into_pod",
170
- "manage_file",
171
- "list_records",
172
- "fetch_record"
173
- ]
174
- },
175
- "dependencies": []
176
- }
@@ -1,104 +0,0 @@
1
- {
2
- "apiVersion": "synap/v1",
3
- "kind": "capability",
4
- "meta": {
5
- "slug": "test-api-3",
6
- "name": "Test API 3",
7
- "description": "Test API 3 capability",
8
- "tags": [
9
- "capability"
10
- ],
11
- "isPublic": true,
12
- "syncByDefault": true
13
- },
14
- "spec": {
15
- "key": "test-api-3",
16
- "name": "Test API 3",
17
- "description": "Test API 3 capability",
18
- "params": [
19
- {
20
- "name": "test-api-3ApiKey",
21
- "label": "Test API 3 API Key",
22
- "type": "text",
23
- "required": true,
24
- "description": "The Test API 3 API key. Stored server-encrypted in the vault; never persisted in the template.",
25
- "obtain": {
26
- "url": "https://example.com/dashboard/keys",
27
- "steps": [
28
- "Obtain your API key from the provider dashboard",
29
- "Copy and paste it here"
30
- ]
31
- }
32
- }
33
- ],
34
- "vault": [
35
- {
36
- "ref": "apiKeySecret",
37
- "name": "{{name}} API key",
38
- "value": "{{test-api-3ApiKey}}",
39
- "type": "api_key",
40
- "description": "API key for the Test API 3 connector."
41
- }
42
- ],
43
- "tools": [
44
- {
45
- "name": "test-api-3_api",
46
- "kind": "api",
47
- "description": "Authenticated HTTP access to the Test API 3 API.",
48
- "credentialRef": "apiKeySecret",
49
- "executor": "is-agent",
50
- "config": {
51
- "baseUrl": "https://api.example.com",
52
- "auth": {
53
- "in": "header",
54
- "name": "Authorization",
55
- "prefix": "Bearer "
56
- }
57
- }
58
- }
59
- ],
60
- "skills": [
61
- {
62
- "name": "test-api-3_search",
63
- "kind": "code",
64
- "scope": "pod",
65
- "requires": [
66
- "test-api-3_api"
67
- ],
68
- "executionMode": "async",
69
- "timeoutSeconds": 60,
70
- "intent": "search_external",
71
- "description": "Search searchs via the TestApi3 API and propose results as test-api-3 entities.",
72
- "parameters": {
73
- "query": "string",
74
- "limit": "number?",
75
- "page": "number?"
76
- },
77
- "code": "// Search skill — calls the API and proposes results as test-api-3 entities\nconst query = String(args?.query ?? '').trim();\nif (!query) throw new Error('query is required');\n\nconst limit = args?.limit ? Math.min(Number(args.limit), 100) : 20;\nconst page = args?.page ? Math.max(Number(args.page), 1) : 1;\nconst path = args?.path || '/search';\n\nconst payload = { q: query, per_page: limit, page };\n\nconst res = await callProvider('test-api-3_api', 'GET', path, payload);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\nconst items = Array.isArray(body) ? body : (body?.items ?? body?.data ?? body?.results ?? []);\n\nif (!ok || items.length === 0) {\n return { success: false, message: 'No results found' };\n}\n\nconst proposed = [];\nfor (const item of items) {\n const r = await propose.entity({\n profileSlug: 'test-api-3',\n title: String(item?.title ?? item?.name ?? item?.id ?? 'result'),\n properties: { ...item, externalId: String(item?.id ?? item?.externalId ?? '') },\n });\n proposed.push(r);\n}\n\nreturn { success: true, count: items.length, proposed };"
78
- },
79
- {
80
- "name": "test-api-3_create",
81
- "kind": "code",
82
- "scope": "pod",
83
- "requires": [
84
- "test-api-3_api"
85
- ],
86
- "executionMode": "async",
87
- "timeoutSeconds": 60,
88
- "intent": "capture_into_pod",
89
- "description": "Create a new create via the TestApi3 API and propose it as a test-api-3 entity.",
90
- "parameters": {
91
- "title": "string",
92
- "properties": "object?",
93
- "externalId": "string?"
94
- },
95
- "code": "// Create skill — POST to API and propose the created entity\nconst title = String(args?.title ?? '').trim();\nif (!title) throw new Error('title is required');\n\nconst path = args?.path || '/create';\nconst payload = { ...args };\ndelete payload.path;\ndelete payload.title;\n\nconst res = await callProvider('test-api-3_api', 'POST', path, payload);\nconst ok = typeof res?.status === 'number' && res.status >= 200 && res.status < 300;\nconst body = res?.body ?? res;\n\nif (!ok) {\n throw new Error(`create failed (${res?.status ?? 'unknown'})`);\n}\n\nconst r = await propose.entity({\n profileSlug: 'test-api-3',\n title,\n properties: { ...body, externalId: String(body?.id ?? body?.externalId ?? '') },\n});\n\nreturn { success: true, proposed: r };"
96
- }
97
- ],
98
- "provides": [
99
- "search_external",
100
- "capture_into_pod"
101
- ]
102
- },
103
- "dependencies": []
104
- }