ns-kiro-core 0.2.0 → 0.2.2
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 +18 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,11 @@ adapters below — not meant to be installed on its own.
|
|
|
12
12
|
- **Endpoints** — SSO region to management/runtime host resolution.
|
|
13
13
|
- **Model catalog** — the bootstrap list, the authenticated regional catalog,
|
|
14
14
|
and a validated on-disk cache at `~/.ns-kiro-provider-models-cache.json`.
|
|
15
|
+
Per-model billing weights (`rateMultiplier`) come from kiro-cli, the only
|
|
16
|
+
source that publishes them.
|
|
17
|
+
- **Usage** — Kiro reports no token counts, only a billed amount, surfaced as
|
|
18
|
+
`usage.credits`. `usage.input` is derived from the context-usage frame and
|
|
19
|
+
`usage.output` from a tiktoken estimate.
|
|
15
20
|
- **Credentials** — reads the kiro-cli SQLite store and the Kiro IDE token file,
|
|
16
21
|
refreshes IDC / desktop / external-IdP / API-key sessions, and writes
|
|
17
22
|
refreshes back so kiro-cli stays on the same token.
|
|
@@ -47,6 +52,19 @@ including across an internal retry, so a host that cannot un-deliver a block
|
|
|
47
52
|
still receives a coherent sequence; `canDiscardEmittedBlocks` tells the core
|
|
48
53
|
which kind of host it is talking to.
|
|
49
54
|
|
|
55
|
+
## The stages underneath
|
|
56
|
+
|
|
57
|
+
`streamKiro` is orchestration over four pieces, each exported for use on its
|
|
58
|
+
own — building a request without sending it, or assembling blocks from events
|
|
59
|
+
sourced elsewhere:
|
|
60
|
+
|
|
61
|
+
| Export | Does |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| `buildKiroRequest` | Neutral messages to a wire request: history shaping, tool specs, pre-send repair. Pure, no I/O |
|
|
64
|
+
| `readKiroEventStream` | AWS event-stream framing and the stall timeouts; yields parsed wire events |
|
|
65
|
+
| `KiroResponseAssembler` | Content blocks, thinking, tool calls, text-dialect recovery, usage, stop reason |
|
|
66
|
+
| `abortableDelay`, `createResponseHeaderDeadline`, `logCapacityEvent` | Transport timing |
|
|
67
|
+
|
|
50
68
|
## Credit
|
|
51
69
|
|
|
52
70
|
Ported from [pi-provider-kiro](https://github.com/mikeyobrien/pi-provider-kiro)
|
package/dist/index.d.ts
CHANGED
|
@@ -12,11 +12,15 @@ export { getKiroIdeCredentials, getKiroIdeCredentialsAllowExpired } from "./kiro
|
|
|
12
12
|
export { fetchKiroModelCatalog, type KiroCatalogModel, type KiroManagementAuth, KiroManagementHttpError, resolveKiroProfileArn, } from "./management.js";
|
|
13
13
|
export { applyEffortLadder, getCachedModels, isCacheStale, KIRO_MANAGEMENT_CACHE_PATH, KIRO_MODEL_IDS, type KiroModel, kiroModels, loadCachedModelIds, mapKiroCatalogModels, resolveKiroModel, updateKiroModelsCache, } from "./models.js";
|
|
14
14
|
export { isApiKey, isExpired, type KiroAuthMethod, type KiroCredentials, kiroAuthHeaders, loginKiroWithApiKey, refreshKiroToken, resolveKiroCredentials, } from "./oauth.js";
|
|
15
|
+
export { type BuildKiroRequestParams, type BuiltKiroRequest, buildKiroRequest, type KiroRequest, } from "./request-builder.js";
|
|
16
|
+
export { type KiroAttemptSummary, type KiroCompletedResponse, KiroResponseAssembler, } from "./response-assembler.js";
|
|
17
|
+
export { IDLE_TIMEOUT, type KiroEventStreamOptions, type KiroEventStreamOutcome, type KiroEventStreamReader, type KiroWireEventFrame, readKiroEventStream, } from "./response-stream.js";
|
|
15
18
|
export { CAPACITY_PATTERN, isCapacityError, isNonRetryableBodyError, isTooBigError, KIRO_REASON_CODES, type KiroReasonCode, NON_RETRYABLE_BODY_PATTERNS, TOO_BIG_PATTERNS, } from "./retry.js";
|
|
16
19
|
export { type KiroStreamRequest, resetProfileArnCache, streamKiro } from "./stream.js";
|
|
17
20
|
export { ThinkingTagParser } from "./thinking-parser.js";
|
|
18
21
|
export { countTokens } from "./tokenizer.js";
|
|
19
22
|
export { buildHistory, EMPTY_CONTENT_PLACEHOLDER, type KiroHistoryEntry, type KiroImage, type KiroToolResult, type KiroToolSpec, type KiroToolUse, type KiroUserInputMessage, normalizeMessages, relocateDisplacedToolResults, sanitizeSurrogates, toKiroToolUseId, } from "./transform.js";
|
|
23
|
+
export { abortableDelay, createResponseHeaderDeadline, logCapacityEvent, type ResponseHeaderDeadline, } from "./transport.js";
|
|
20
24
|
export { TRUNCATION_NOTICE, wasPreviousResponseTruncated } from "./truncation.js";
|
|
21
25
|
export * from "./types.js";
|
|
22
26
|
export { fetchKiroUsage, type KiroProviderUsage, type KiroProviderUsageBucket } from "./usage.js";
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,12 @@ export { getKiroIdeCredentials, getKiroIdeCredentialsAllowExpired } from "./kiro
|
|
|
13
13
|
export { fetchKiroModelCatalog, KiroManagementHttpError, resolveKiroProfileArn, } from "./management.js";
|
|
14
14
|
export { applyEffortLadder, getCachedModels, isCacheStale, KIRO_MANAGEMENT_CACHE_PATH, KIRO_MODEL_IDS, kiroModels, loadCachedModelIds, mapKiroCatalogModels, resolveKiroModel, updateKiroModelsCache, } from "./models.js";
|
|
15
15
|
export { isApiKey, isExpired, kiroAuthHeaders, loginKiroWithApiKey, refreshKiroToken, resolveKiroCredentials, } from "./oauth.js";
|
|
16
|
+
// The stages `streamKiro` runs in order. Exported so a caller can drive one on
|
|
17
|
+
// its own — building a request without sending it, or assembling blocks from
|
|
18
|
+
// events it sourced elsewhere — which is what splitting them apart was for.
|
|
19
|
+
export { buildKiroRequest, } from "./request-builder.js";
|
|
20
|
+
export { KiroResponseAssembler, } from "./response-assembler.js";
|
|
21
|
+
export { IDLE_TIMEOUT, readKiroEventStream, } from "./response-stream.js";
|
|
16
22
|
// Kiro's own error vocabulary and the predicates this core classifies it with.
|
|
17
23
|
// Published so consumers can interpret a reason code without an error instance
|
|
18
24
|
// in hand (a persisted log line, say) instead of hardcoding copies of the
|
|
@@ -22,6 +28,7 @@ export { resetProfileArnCache, streamKiro } from "./stream.js";
|
|
|
22
28
|
export { ThinkingTagParser } from "./thinking-parser.js";
|
|
23
29
|
export { countTokens } from "./tokenizer.js";
|
|
24
30
|
export { buildHistory, EMPTY_CONTENT_PLACEHOLDER, normalizeMessages, relocateDisplacedToolResults, sanitizeSurrogates, toKiroToolUseId, } from "./transform.js";
|
|
31
|
+
export { abortableDelay, createResponseHeaderDeadline, logCapacityEvent, } from "./transport.js";
|
|
25
32
|
export { TRUNCATION_NOTICE, wasPreviousResponseTruncated } from "./truncation.js";
|
|
26
33
|
export * from "./types.js";
|
|
27
34
|
export { fetchKiroUsage } from "./usage.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,EACL,qCAAqC,EACrC,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EAInB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EAEzB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA0C,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,EAKxB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,iCAAiC,EACjC,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAA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