@aliyunrds/ctxdb 1.0.7 → 1.0.8-beta.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/README.internal.md +59 -0
- package/README.md +160 -12
- package/dist/{chunk-NFTGG6WK.js → chunk-24CNB3XJ.js} +2 -2
- package/dist/{chunk-S5W4FQ7M.js → chunk-AAZLOCVB.js} +219 -24
- package/dist/{chunk-R2QS6ACP.js → chunk-BBTXHFMD.js} +1 -1
- package/dist/{chunk-QVXDI77N.js → chunk-CAXRYH6E.js} +1 -1
- package/dist/{chunk-DC5NWGDW.js → chunk-HF2CWTRU.js} +2 -2
- package/dist/{chunk-X2BX6LR6.js → chunk-NJJBT52C.js} +1 -1
- package/dist/chunk-R67JELM7.js +20 -0
- package/dist/{chunk-Z6OHSEF2.js → chunk-ULAWTBBC.js} +34 -16
- package/dist/chunk-VIG4SYLU.js +8 -0
- package/dist/{chunk-DPLMBHLU.js → chunk-WSMZOFZQ.js} +3 -3
- package/dist/cli/main.js +1508 -60
- package/dist/hooks/hermes-post-llm-call.js +6 -4
- package/dist/hooks/hermes-pre-llm-call.js +9 -7
- package/dist/hooks/pre-tool-use.js +2 -1
- package/dist/hooks/session-start.js +8 -6
- package/dist/hooks/stop.js +6 -4
- package/dist/hooks/user-prompt-submit.js +8 -6
- package/dist/opencode/index.js +58 -2
- package/dist/workers/version-check.js +3 -1
- package/package.json +5 -1
- /package/dist/{chunk-UEKR2Z3S.js → chunk-5ML4VSXN.js} +0 -0
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
captureParsedMessages
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-HF2CWTRU.js";
|
|
5
|
+
import "../chunk-NJJBT52C.js";
|
|
6
6
|
import {
|
|
7
7
|
HttpClient,
|
|
8
8
|
agentFromArgvWithFallback,
|
|
9
9
|
debug,
|
|
10
10
|
load,
|
|
11
11
|
setDebug
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-AAZLOCVB.js";
|
|
13
13
|
import {
|
|
14
14
|
shouldSkipHooks
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-5ML4VSXN.js";
|
|
16
|
+
import "../chunk-R67JELM7.js";
|
|
17
|
+
import "../chunk-VIG4SYLU.js";
|
|
16
18
|
|
|
17
19
|
// src/hooks/hermes-post-llm-call.ts
|
|
18
20
|
import { pathToFileURL } from "url";
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import {
|
|
3
3
|
HOOK_TIMEOUT_MS,
|
|
4
4
|
composeSessionStart
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-24CNB3XJ.js";
|
|
6
6
|
import {
|
|
7
7
|
composeUserPromptSubmit
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-BBTXHFMD.js";
|
|
9
9
|
import {
|
|
10
10
|
fetchKbCatalogBlock
|
|
11
|
-
} from "../chunk-
|
|
12
|
-
import "../chunk-
|
|
11
|
+
} from "../chunk-WSMZOFZQ.js";
|
|
12
|
+
import "../chunk-CAXRYH6E.js";
|
|
13
13
|
import {
|
|
14
14
|
isCircuitOpen
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-NJJBT52C.js";
|
|
16
16
|
import {
|
|
17
17
|
HttpClient,
|
|
18
18
|
agentFromArgvWithFallback,
|
|
@@ -20,10 +20,12 @@ import {
|
|
|
20
20
|
isComplete,
|
|
21
21
|
load,
|
|
22
22
|
setDebug
|
|
23
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-AAZLOCVB.js";
|
|
24
24
|
import {
|
|
25
25
|
shouldSkipHooks
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-5ML4VSXN.js";
|
|
27
|
+
import "../chunk-R67JELM7.js";
|
|
28
|
+
import "../chunk-VIG4SYLU.js";
|
|
27
29
|
|
|
28
30
|
// src/hooks/hermes-pre-llm-call.ts
|
|
29
31
|
import { pathToFileURL } from "url";
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
HOOK_TIMEOUT_MS,
|
|
4
4
|
composeSessionStart,
|
|
5
5
|
formatSessionStartStdout
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-24CNB3XJ.js";
|
|
7
|
+
import "../chunk-WSMZOFZQ.js";
|
|
8
|
+
import "../chunk-CAXRYH6E.js";
|
|
9
9
|
import {
|
|
10
10
|
isCircuitOpen
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-NJJBT52C.js";
|
|
12
12
|
import {
|
|
13
13
|
HttpClient,
|
|
14
14
|
agentFromArgvWithFallback,
|
|
@@ -16,10 +16,12 @@ import {
|
|
|
16
16
|
isComplete,
|
|
17
17
|
load,
|
|
18
18
|
setDebug
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-AAZLOCVB.js";
|
|
20
20
|
import {
|
|
21
21
|
shouldSkipHooks
|
|
22
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-5ML4VSXN.js";
|
|
23
|
+
import "../chunk-R67JELM7.js";
|
|
24
|
+
import "../chunk-VIG4SYLU.js";
|
|
23
25
|
|
|
24
26
|
// src/hooks/session-start.ts
|
|
25
27
|
import { pathToFileURL } from "url";
|
package/dist/hooks/stop.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
captureTurn
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-HF2CWTRU.js";
|
|
5
|
+
import "../chunk-NJJBT52C.js";
|
|
6
6
|
import {
|
|
7
7
|
HttpClient,
|
|
8
8
|
agentFromArgvWithFallback,
|
|
9
9
|
debug,
|
|
10
10
|
load,
|
|
11
11
|
setDebug
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-AAZLOCVB.js";
|
|
13
13
|
import {
|
|
14
14
|
shouldSkipHooks
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-5ML4VSXN.js";
|
|
16
|
+
import "../chunk-R67JELM7.js";
|
|
17
|
+
import "../chunk-VIG4SYLU.js";
|
|
16
18
|
|
|
17
19
|
// src/hooks/stop.ts
|
|
18
20
|
async function readStdinJson() {
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import {
|
|
3
3
|
composeUserPromptSubmit,
|
|
4
4
|
formatUserPromptSubmitStdout
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-BBTXHFMD.js";
|
|
6
|
+
import "../chunk-WSMZOFZQ.js";
|
|
7
|
+
import "../chunk-CAXRYH6E.js";
|
|
8
8
|
import {
|
|
9
9
|
isCircuitOpen
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-NJJBT52C.js";
|
|
11
11
|
import {
|
|
12
12
|
HttpClient,
|
|
13
13
|
agentFromArgvWithFallback,
|
|
@@ -15,10 +15,12 @@ import {
|
|
|
15
15
|
isComplete,
|
|
16
16
|
load,
|
|
17
17
|
setDebug
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-AAZLOCVB.js";
|
|
19
19
|
import {
|
|
20
20
|
shouldSkipHooks
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-5ML4VSXN.js";
|
|
22
|
+
import "../chunk-R67JELM7.js";
|
|
23
|
+
import "../chunk-VIG4SYLU.js";
|
|
22
24
|
|
|
23
25
|
// src/hooks/user-prompt-submit.ts
|
|
24
26
|
import { pathToFileURL } from "url";
|
package/dist/opencode/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
// <define:__CTXDB_DISTRIBUTION_MANIFEST__>
|
|
2
|
+
var define_CTXDB_DISTRIBUTION_MANIFEST_default = { id: "public", packageName: "@aliyunrds/ctxdb", packageRegistry: null, capabilities: { interactiveLogin: false, managedCredentials: false } };
|
|
3
|
+
|
|
1
4
|
// src/config.ts
|
|
2
|
-
import { readFileSync as readFileSync2, existsSync as existsSync2 } from "fs";
|
|
5
|
+
import { readFileSync as readFileSync2, existsSync as existsSync2, statSync as statSync2 } from "fs";
|
|
3
6
|
import { homedir as homedir2 } from "os";
|
|
4
|
-
import { join as join2 } from "path";
|
|
7
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
5
8
|
|
|
6
9
|
// ../shared/src/graph-context.ts
|
|
7
10
|
var GRAPH_CONTEXT_TAG = "graphrag";
|
|
@@ -828,6 +831,18 @@ function isRecallTraceRecord(value) {
|
|
|
828
831
|
return isNonNegativeFinite(record.duration_ms) && typeof record.outcome === "string" && TRACE_OUTCOMES.has(record.outcome) && (typeof record.failure_reason === "string" || record.failure_reason === null) && Array.isArray(record.returned_memories) && Array.isArray(record.returned_knowledge) && Boolean(selection) && Array.isArray(selection?.selected) && Array.isArray(selection?.excluded) && isNonNegativeFinite(selection?.token_estimate) && typeof record.recall_context === "string";
|
|
829
832
|
}
|
|
830
833
|
|
|
834
|
+
// src/distribution-capabilities.ts
|
|
835
|
+
var PUBLIC_DISTRIBUTION = {
|
|
836
|
+
id: "public",
|
|
837
|
+
packageName: "@aliyunrds/ctxdb",
|
|
838
|
+
packageRegistry: null,
|
|
839
|
+
capabilities: {
|
|
840
|
+
interactiveLogin: false,
|
|
841
|
+
managedCredentials: false
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
var DISTRIBUTION_MANIFEST = typeof define_CTXDB_DISTRIBUTION_MANIFEST_default === "undefined" ? PUBLIC_DISTRIBUTION : define_CTXDB_DISTRIBUTION_MANIFEST_default;
|
|
845
|
+
|
|
831
846
|
// src/config.ts
|
|
832
847
|
var DEFAULT_BASE_URL = "https://context-database.aliyuncs.com";
|
|
833
848
|
var DEFAULT_USER_ID = "default";
|
|
@@ -893,6 +908,40 @@ function applyDebugPolicy(cfg) {
|
|
|
893
908
|
cfg.debugReason = policy.debugReason;
|
|
894
909
|
return cfg;
|
|
895
910
|
}
|
|
911
|
+
function managedCredential(path) {
|
|
912
|
+
if (!existsSync2(path)) return null;
|
|
913
|
+
if (process.platform !== "win32" && (statSync2(path).mode & 63) !== 0) {
|
|
914
|
+
throw new Error(`credentials: ${path} must be owner-only (run chmod 600)`);
|
|
915
|
+
}
|
|
916
|
+
const raw = JSON.parse(readFileSync2(path, "utf8"));
|
|
917
|
+
if (raw.version !== 1 || !raw.records || typeof raw.records !== "object") {
|
|
918
|
+
throw new Error("credentials: unsupported credentials.json schema");
|
|
919
|
+
}
|
|
920
|
+
const unknownKeys = Object.keys(raw.records).filter(
|
|
921
|
+
(key) => key !== "contextdb/active"
|
|
922
|
+
);
|
|
923
|
+
if (unknownKeys.length > 0) {
|
|
924
|
+
throw new Error(`credentials: unsupported record key ${unknownKeys[0]}`);
|
|
925
|
+
}
|
|
926
|
+
const record = raw.records["contextdb/active"];
|
|
927
|
+
if (!record) return null;
|
|
928
|
+
if (record.kind !== "api-key" || typeof record.payload?.api_key !== "string" || !record.payload.api_key || typeof record.payload?.base_url !== "string" || !record.payload.base_url) {
|
|
929
|
+
throw new Error("credentials: invalid contextdb/active record");
|
|
930
|
+
}
|
|
931
|
+
let baseUrl;
|
|
932
|
+
try {
|
|
933
|
+
baseUrl = new URL(record.payload.base_url);
|
|
934
|
+
} catch {
|
|
935
|
+
throw new Error("credentials: invalid contextdb/active base_url");
|
|
936
|
+
}
|
|
937
|
+
if (!["https:", "http:"].includes(baseUrl.protocol) || baseUrl.username || baseUrl.password || baseUrl.search || baseUrl.hash) {
|
|
938
|
+
throw new Error("credentials: invalid contextdb/active base_url");
|
|
939
|
+
}
|
|
940
|
+
return {
|
|
941
|
+
apiKey: record.payload.api_key,
|
|
942
|
+
baseUrl: baseUrl.toString().replace(/\/$/, "")
|
|
943
|
+
};
|
|
944
|
+
}
|
|
896
945
|
function loadOpencodeConfig(options = {}) {
|
|
897
946
|
const env = options.env ?? process.env;
|
|
898
947
|
const path = options.path ?? defaultPath(env);
|
|
@@ -918,6 +967,13 @@ function loadOpencodeConfig(options = {}) {
|
|
|
918
967
|
debugReason: null,
|
|
919
968
|
kbCatalogInjection: coerceKbCatalogInjection(section.kb_catalog_injection)
|
|
920
969
|
};
|
|
970
|
+
const managed = DISTRIBUTION_MANIFEST.capabilities.managedCredentials && options.managedCredentials !== false ? managedCredential(
|
|
971
|
+
options.credentialsPath ?? join2(dirname2(path), "credentials.json")
|
|
972
|
+
) : null;
|
|
973
|
+
if (managed) {
|
|
974
|
+
cfg.apiKey = managed.apiKey;
|
|
975
|
+
cfg.baseUrl = managed.baseUrl;
|
|
976
|
+
}
|
|
921
977
|
return applyEnv(cfg, env);
|
|
922
978
|
}
|
|
923
979
|
function isConfigured(cfg) {
|
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
recordVersionCheckFailure,
|
|
5
5
|
recordVersionCheckSuccess,
|
|
6
6
|
releaseVersionCheckLock
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-ULAWTBBC.js";
|
|
8
|
+
import "../chunk-R67JELM7.js";
|
|
9
|
+
import "../chunk-VIG4SYLU.js";
|
|
8
10
|
|
|
9
11
|
// src/workers/version-check.ts
|
|
10
12
|
import { fileURLToPath } from "url";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aliyunrds/ctxdb",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Unified access layer for RDS ContextDatabase: `ctxdb` CLI (memory + KB ops), one-shot `setup --agent <qoder|qoderwork|codex|claude|opencode|hermes>` installer, per-agent config, hooks/plugins, and SKILL.md.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsup && pnpm --dir ../opencode build && mkdir -p dist/setup dist/opencode && cp ../opencode/dist/index.js dist/opencode/index.js && cp -r src/setup/skills dist/setup/ && chmod +x dist/hooks/*.js dist/cli/main.js",
|
|
47
|
+
"build:internal": "tsup --config tsup.internal.config.ts && pnpm --dir ../opencode build:internal && mkdir -p dist-internal/setup dist-internal/opencode && cp ../opencode/dist-internal/index.js dist-internal/opencode/index.js && cp -r src/setup/skills dist-internal/setup/ && chmod +x dist-internal/hooks/*.js dist-internal/cli/internal-main.js && node scripts/prepare-internal-package.mjs",
|
|
48
|
+
"test:distributions": "node scripts/smoke-distribution-builds.mjs",
|
|
49
|
+
"test:e2e:distributions:prepared": "node scripts/prepare-distribution-e2e.mjs && vitest run --config vitest.e2e.config.ts",
|
|
50
|
+
"test:e2e:distributions": "pnpm --dir ../shared build && pnpm build && pnpm build:internal && pnpm test:e2e:distributions:prepared",
|
|
47
51
|
"test": "vitest run"
|
|
48
52
|
}
|
|
49
53
|
}
|
|
File without changes
|