@indexnetwork/cli 0.30.0-rc.94.1 → 0.30.0-rc.98.1
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 +2 -2
- package/dist/index.js +43 -17
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -56,8 +56,8 @@ flags are listed in [Options](#options), and examples follow this reference.
|
|
|
56
56
|
| `index intent list` | List intents, with optional archived, text-query, and result-limit filters. |
|
|
57
57
|
| `index intent show <id>` | Show one intent. |
|
|
58
58
|
| `index intent prepare <text>` | Prepare a draft, optionally answering recovery prompts; returns an admission receipt when ready. |
|
|
59
|
-
| `index intent create <text>` | Create an intent, optionally using the preparation receipt
|
|
60
|
-
| `index intent update <id> <text
|
|
59
|
+
| `index intent create <text>` | Create an intent, optionally using the preparation receipt and client-owned `--source-type` / `--source-id`. |
|
|
60
|
+
| `index intent update <id> [<text>]` | Update and reprocess an intent's description, or set `--source-type` / `--source-id` (empty clears). |
|
|
61
61
|
| `index intent archive <id>` | Archive an intent so it stops participating in discovery. |
|
|
62
62
|
| `index intent pause <id>` / `resume <id>` | Pause or resume its agent without archiving. |
|
|
63
63
|
| `index intent networks <id>` | List the networks an intent is shared in. |
|
package/dist/index.js
CHANGED
|
@@ -95,7 +95,7 @@ function parseArgs(args) {
|
|
|
95
95
|
return { ...result, command: "version" };
|
|
96
96
|
if (["--api-url", "--app-url", "--status", "--limit", "--prompt", "-p", "--objective", "--title"].includes(arg) && (!args[i + 1] || args[i + 1].startsWith("--")))
|
|
97
97
|
throw new Error(`Missing value for ${arg}`);
|
|
98
|
-
if (["--query", "--state", "--action", "--message", "--intent-id", "--question-id", "--receipt", "--name", "--intro", "--location", "--statuses", "--answer", "--social"].includes(arg)) {
|
|
98
|
+
if (["--query", "--state", "--action", "--message", "--intent-id", "--question-id", "--receipt", "--source-type", "--source-id", "--name", "--intro", "--location", "--statuses", "--answer", "--social"].includes(arg)) {
|
|
99
99
|
const value = args[i + 1];
|
|
100
100
|
if (value === undefined || value.startsWith("--"))
|
|
101
101
|
throw new Error(`Missing value for ${arg}`);
|
|
@@ -121,6 +121,12 @@ function parseArgs(args) {
|
|
|
121
121
|
case "--receipt":
|
|
122
122
|
result.receipt = value;
|
|
123
123
|
break;
|
|
124
|
+
case "--source-type":
|
|
125
|
+
result.sourceType = value;
|
|
126
|
+
break;
|
|
127
|
+
case "--source-id":
|
|
128
|
+
result.sourceId = value;
|
|
129
|
+
break;
|
|
124
130
|
case "--name":
|
|
125
131
|
result.name = value;
|
|
126
132
|
break;
|
|
@@ -451,11 +457,12 @@ class ApiClient {
|
|
|
451
457
|
const body = await res.json();
|
|
452
458
|
return body.intent;
|
|
453
459
|
}
|
|
454
|
-
async createIntent(description, networkIds, preparationReceipt) {
|
|
460
|
+
async createIntent(description, networkIds, preparationReceipt, source = {}) {
|
|
455
461
|
const res = await this.post("/api/intents", {
|
|
456
462
|
description,
|
|
457
463
|
...networkIds?.length ? { networkIds } : {},
|
|
458
|
-
...preparationReceipt ? { preparationReceipt } : {}
|
|
464
|
+
...preparationReceipt ? { preparationReceipt } : {},
|
|
465
|
+
...source
|
|
459
466
|
});
|
|
460
467
|
return await res.json();
|
|
461
468
|
}
|
|
@@ -466,8 +473,11 @@ class ApiClient {
|
|
|
466
473
|
async updateIntentStatus(id, status) {
|
|
467
474
|
await this.patch(`/api/intents/${encodeURIComponent(id)}/status`, { status });
|
|
468
475
|
}
|
|
469
|
-
async updateIntent(intentId, description) {
|
|
470
|
-
const res = await this.patch(`/api/intents/${encodeURIComponent(intentId)}`, {
|
|
476
|
+
async updateIntent(intentId, description, source = {}) {
|
|
477
|
+
const res = await this.patch(`/api/intents/${encodeURIComponent(intentId)}`, {
|
|
478
|
+
...description !== undefined ? { description } : {},
|
|
479
|
+
...source
|
|
480
|
+
});
|
|
471
481
|
return await res.json();
|
|
472
482
|
}
|
|
473
483
|
async archiveIntent(intentId) {
|
|
@@ -1102,7 +1112,7 @@ function intentTable(intents) {
|
|
|
1102
1112
|
month: "short",
|
|
1103
1113
|
day: "numeric"
|
|
1104
1114
|
});
|
|
1105
|
-
const sColor = intent.status === "
|
|
1115
|
+
const sColor = intent.status === "active" ? GREEN : GRAY;
|
|
1106
1116
|
console.log(` ${CYAN}${shortId}${RESET} ${desc.padEnd(descWidth)} ${sColor}${status}${RESET} ${GRAY}${source}${RESET} ${GRAY}${date}${RESET}`);
|
|
1107
1117
|
}
|
|
1108
1118
|
}
|
|
@@ -1147,7 +1157,7 @@ function intentCard(intent) {
|
|
|
1147
1157
|
console.log(` ${BOLD}${CYAN}Intent Details${RESET}`);
|
|
1148
1158
|
console.log(` ${GRAY}${"─".repeat(50)}${RESET}`);
|
|
1149
1159
|
console.log(` ${BOLD}ID${RESET} ${GRAY}${intent.id}${RESET}`);
|
|
1150
|
-
console.log(` ${BOLD}Status${RESET} ${intent.status === "
|
|
1160
|
+
console.log(` ${BOLD}Status${RESET} ${intent.status === "active" ? GREEN : GRAY}${intent.status}${RESET}`);
|
|
1151
1161
|
if (intent.summary) {
|
|
1152
1162
|
console.log(` ${BOLD}Summary${RESET} ${intent.summary}`);
|
|
1153
1163
|
}
|
|
@@ -1162,7 +1172,10 @@ function intentCard(intent) {
|
|
|
1162
1172
|
console.log(` ${BOLD}Mode${RESET} ${intent.intentMode}`);
|
|
1163
1173
|
}
|
|
1164
1174
|
if (intent.sourceType) {
|
|
1165
|
-
console.log(` ${BOLD}Source${RESET}
|
|
1175
|
+
console.log(` ${BOLD}Source type${RESET} ${intent.sourceType}`);
|
|
1176
|
+
}
|
|
1177
|
+
if (intent.sourceId) {
|
|
1178
|
+
console.log(` ${BOLD}Source ID${RESET} ${intent.sourceId}`);
|
|
1166
1179
|
}
|
|
1167
1180
|
if (intent.confidence !== undefined) {
|
|
1168
1181
|
console.log(` ${BOLD}Confidence${RESET} ${confidenceBar(intent.confidence)}`);
|
|
@@ -1671,15 +1684,26 @@ Usage:
|
|
|
1671
1684
|
index intent list [--archived] [--limit <n>] [--query <text>] List your intents
|
|
1672
1685
|
index intent show <id> Show intent details (accepts short ID)
|
|
1673
1686
|
index intent prepare <content> [--answer 'prompt=reply'] Review and repair a draft
|
|
1674
|
-
index intent create <content> [--receipt <token>]
|
|
1687
|
+
index intent create <content> [--receipt <token>] [--source-type <s>] [--source-id <s>] Create an admitted intent
|
|
1675
1688
|
index intent pause <id> | resume <id> Hold or restart its agent
|
|
1676
|
-
index intent update <id> <content>
|
|
1689
|
+
index intent update <id> [<content>] [--source-type <s>] [--source-id <s>] Update description or source fields
|
|
1677
1690
|
index intent archive <id> Archive an intent (accepts short ID)
|
|
1678
1691
|
index intent networks <id> List the networks an intent is shared in
|
|
1679
1692
|
index intent add-to-network <id> <network-id> Add an intent to a network
|
|
1680
1693
|
index intent remove-from-network <id> <network-id> Remove an intent from a network
|
|
1694
|
+
|
|
1695
|
+
--source-type and --source-id are optional strings Index stores and returns
|
|
1696
|
+
unchanged, so a client can map its own records (such as an inferred ambient
|
|
1697
|
+
intent) to the published signal. Pass an empty value to clear one on update.
|
|
1681
1698
|
`;
|
|
1699
|
+
function sourceField(value) {
|
|
1700
|
+
return value === undefined ? undefined : value || null;
|
|
1701
|
+
}
|
|
1682
1702
|
async function handleIntent(client, subcommand, options) {
|
|
1703
|
+
const source = {
|
|
1704
|
+
...options.sourceType !== undefined ? { sourceType: sourceField(options.sourceType) } : {},
|
|
1705
|
+
...options.sourceId !== undefined ? { sourceId: sourceField(options.sourceId) } : {}
|
|
1706
|
+
};
|
|
1683
1707
|
if (!subcommand) {
|
|
1684
1708
|
if (options.json) {
|
|
1685
1709
|
console.log(JSON.stringify({ error: "No subcommand provided" }));
|
|
@@ -1739,7 +1763,7 @@ async function handleIntent(client, subcommand, options) {
|
|
|
1739
1763
|
}
|
|
1740
1764
|
if (!options.json)
|
|
1741
1765
|
info("Processing intent...");
|
|
1742
|
-
const result = await client.createIntent(options.intentContent, options.targetId ? [options.targetId] : undefined, options.receipt);
|
|
1766
|
+
const result = await client.createIntent(options.intentContent, options.targetId ? [options.targetId] : undefined, options.receipt, source);
|
|
1743
1767
|
if (options.json) {
|
|
1744
1768
|
console.log(JSON.stringify(result));
|
|
1745
1769
|
return;
|
|
@@ -1750,16 +1774,16 @@ async function handleIntent(client, subcommand, options) {
|
|
|
1750
1774
|
}
|
|
1751
1775
|
case "update": {
|
|
1752
1776
|
if (!options.intentId) {
|
|
1753
|
-
error("Missing intent ID. Usage: index intent update <id> <content>", 1);
|
|
1777
|
+
error("Missing intent ID. Usage: index intent update <id> [<content>] [--source-type <s>] [--source-id <s>]", 1);
|
|
1754
1778
|
return;
|
|
1755
1779
|
}
|
|
1756
|
-
if (!options.intentContent) {
|
|
1757
|
-
error("
|
|
1780
|
+
if (!options.intentContent && Object.keys(source).length === 0) {
|
|
1781
|
+
error("Nothing to update. Usage: index intent update <id> [<content>] [--source-type <s>] [--source-id <s>]", 1);
|
|
1758
1782
|
return;
|
|
1759
1783
|
}
|
|
1760
1784
|
if (!options.json)
|
|
1761
1785
|
info("Updating intent...");
|
|
1762
|
-
const result = await client.updateIntent(options.intentId, options.intentContent);
|
|
1786
|
+
const result = await client.updateIntent(options.intentId, options.intentContent, source);
|
|
1763
1787
|
if (options.json) {
|
|
1764
1788
|
console.log(JSON.stringify(result));
|
|
1765
1789
|
return;
|
|
@@ -1771,7 +1795,7 @@ async function handleIntent(client, subcommand, options) {
|
|
|
1771
1795
|
case "resume": {
|
|
1772
1796
|
if (!options.intentId)
|
|
1773
1797
|
throw new Error(`Usage: index intent ${subcommand} <id>`);
|
|
1774
|
-
const status = subcommand === "pause" ? "
|
|
1798
|
+
const status = subcommand === "pause" ? "paused" : "active";
|
|
1775
1799
|
await client.updateIntentStatus(options.intentId, status);
|
|
1776
1800
|
if (options.json)
|
|
1777
1801
|
console.log(JSON.stringify({ intentId: options.intentId, status }));
|
|
@@ -2694,7 +2718,9 @@ async function main() {
|
|
|
2694
2718
|
targetId: args.targetId,
|
|
2695
2719
|
query: args.query,
|
|
2696
2720
|
receipt: args.receipt,
|
|
2697
|
-
answers: args.answers
|
|
2721
|
+
answers: args.answers,
|
|
2722
|
+
sourceType: args.sourceType,
|
|
2723
|
+
sourceId: args.sourceId
|
|
2698
2724
|
});
|
|
2699
2725
|
return;
|
|
2700
2726
|
case "opportunity":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indexnetwork/cli",
|
|
3
|
-
"version": "0.30.0-rc.
|
|
3
|
+
"version": "0.30.0-rc.98.1",
|
|
4
4
|
"description": "Command-line interface for Index Network",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"publish:all": "bun scripts/publish.ts"
|
|
21
21
|
},
|
|
22
22
|
"optionalDependencies": {
|
|
23
|
-
"@indexnetwork/cli-linux-x64": "0.30.0-rc.
|
|
24
|
-
"@indexnetwork/cli-linux-arm64": "0.30.0-rc.
|
|
25
|
-
"@indexnetwork/cli-darwin-x64": "0.30.0-rc.
|
|
26
|
-
"@indexnetwork/cli-darwin-arm64": "0.30.0-rc.
|
|
23
|
+
"@indexnetwork/cli-linux-x64": "0.30.0-rc.98.1",
|
|
24
|
+
"@indexnetwork/cli-linux-arm64": "0.30.0-rc.98.1",
|
|
25
|
+
"@indexnetwork/cli-darwin-x64": "0.30.0-rc.98.1",
|
|
26
|
+
"@indexnetwork/cli-darwin-arm64": "0.30.0-rc.98.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/bun": "1.3.14"
|