t3code-cli 0.13.0 → 0.14.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.md +87 -1
- package/dist/application.d.ts +2 -0
- package/dist/application.js +1 -1
- package/dist/auth.d.ts +50 -0
- package/dist/auth.js +1 -1
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +348 -603
- package/dist/cli.d.ts +66 -0
- package/dist/cli.js +1 -1
- package/dist/client-runtime/authorization.d.ts +2 -0
- package/dist/client-runtime/authorization.js +2 -0
- package/dist/client-runtime/connection.d.ts +2 -0
- package/dist/client-runtime/connection.js +2 -0
- package/dist/client-runtime/environment.d.ts +57 -0
- package/dist/client-runtime/environment.js +2 -0
- package/dist/client-runtime/errors.d.ts +28 -0
- package/dist/client-runtime/errors.js +35 -0
- package/dist/client-runtime/operations/projects.d.ts +2 -0
- package/dist/client-runtime/operations/projects.js +2 -0
- package/dist/client-runtime/operations.d.ts +2 -0
- package/dist/client-runtime/operations.js +2 -0
- package/dist/client-runtime/platform.d.ts +26 -0
- package/dist/client-runtime/platform.js +74 -0
- package/dist/client-runtime/relay.d.ts +121 -0
- package/dist/client-runtime/relay.js +245 -0
- package/dist/client-runtime/rpc.d.ts +2 -0
- package/dist/client-runtime/rpc.js +2 -0
- package/dist/client-runtime/state/assets.d.ts +40 -0
- package/dist/client-runtime/state/assets.js +53 -0
- package/dist/client-runtime/state/auth.d.ts +98 -0
- package/dist/client-runtime/state/auth.js +48 -0
- package/dist/client-runtime/state/connections.d.ts +2 -0
- package/dist/client-runtime/state/connections.js +52 -0
- package/dist/client-runtime/state/entities.d.ts +33 -0
- package/dist/client-runtime/state/entities.js +2 -0
- package/dist/client-runtime/state/filesystem.d.ts +42 -0
- package/dist/client-runtime/state/filesystem.js +48 -0
- package/dist/client-runtime/state/git.d.ts +43 -0
- package/dist/client-runtime/state/git.js +18 -0
- package/dist/client-runtime/state/models.d.ts +2 -0
- package/dist/client-runtime/state/models.js +2 -0
- package/dist/client-runtime/state/orchestration.d.ts +128 -0
- package/dist/client-runtime/state/orchestration.js +20 -0
- package/dist/client-runtime/state/presentation.d.ts +277 -0
- package/dist/client-runtime/state/presentation.js +34 -0
- package/dist/client-runtime/state/preview.d.ts +447 -0
- package/dist/client-runtime/state/preview.js +103 -0
- package/dist/client-runtime/state/project-grouping.d.ts +26 -0
- package/dist/client-runtime/state/project-grouping.js +73 -0
- package/dist/client-runtime/state/projects.d.ts +192 -0
- package/dist/client-runtime/state/projects.js +2 -0
- package/dist/client-runtime/state/relay.d.ts +10 -0
- package/dist/client-runtime/state/relay.js +19 -0
- package/dist/client-runtime/state/review.d.ts +28 -0
- package/dist/client-runtime/state/review.js +11 -0
- package/dist/client-runtime/state/runtime.d.ts +2 -0
- package/dist/client-runtime/state/runtime.js +2 -0
- package/dist/client-runtime/state/server.d.ts +1495 -0
- package/dist/client-runtime/state/server.js +207 -0
- package/dist/client-runtime/state/session.d.ts +532 -0
- package/dist/client-runtime/state/session.js +21 -0
- package/dist/client-runtime/state/shell.d.ts +529 -0
- package/dist/client-runtime/state/shell.js +2 -0
- package/dist/client-runtime/state/source-control.d.ts +92 -0
- package/dist/client-runtime/state/source-control.js +36 -0
- package/dist/client-runtime/state/terminal.d.ts +237 -0
- package/dist/client-runtime/state/terminal.js +173 -0
- package/dist/client-runtime/state/thread-settled.d.ts +104 -0
- package/dist/client-runtime/state/thread-settled.js +157 -0
- package/dist/client-runtime/state/thread-sort.d.ts +23 -0
- package/dist/client-runtime/state/thread-sort.js +47 -0
- package/dist/client-runtime/state/threads.d.ts +538 -0
- package/dist/client-runtime/state/threads.js +934 -0
- package/dist/client-runtime/state/vcs.d.ts +442 -0
- package/dist/client-runtime/state/vcs.js +756 -0
- package/dist/config.d.ts +84 -0
- package/dist/config.js +1 -1
- package/dist/connection.d.ts +7 -0
- package/dist/connection.js +1 -1
- package/dist/contracts.d.ts +2 -0
- package/dist/contracts.js +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/node.d.ts +6 -0
- package/dist/node.js +1 -1
- package/dist/orchestration.d.ts +1420 -0
- package/dist/orchestration.js +1 -1
- package/dist/preview.d.ts +2 -0
- package/dist/preview.js +2 -0
- package/dist/rpc.d.ts +6043 -0
- package/dist/rpc.js +1 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +2 -2
- package/dist/shared/DrainableWorker.d.ts +28 -0
- package/dist/shared/DrainableWorker.js +24 -0
- package/dist/shared/KeyedCoalescingWorker.d.ts +13 -0
- package/dist/shared/KeyedCoalescingWorker.js +89 -0
- package/dist/shared/Net.d.ts +43 -0
- package/dist/shared/Net.js +126 -0
- package/dist/shared/String.d.ts +4 -0
- package/dist/shared/String.js +8 -0
- package/dist/shared/Struct.d.ts +5 -0
- package/dist/shared/Struct.js +2 -0
- package/dist/shared/advertisedEndpoint.d.ts +2 -0
- package/dist/shared/advertisedEndpoint.js +2 -0
- package/dist/shared/agentAwareness.d.ts +27 -0
- package/dist/shared/agentAwareness.js +54 -0
- package/dist/shared/backgroundActivitySettings.d.ts +23 -0
- package/dist/shared/backgroundActivitySettings.js +2 -0
- package/dist/shared/chatList.d.ts +12 -0
- package/dist/shared/chatList.js +14 -0
- package/dist/shared/cliArgs.d.ts +33 -0
- package/dist/shared/cliArgs.js +103 -0
- package/dist/shared/composerInlineTokens.d.ts +20 -0
- package/dist/shared/composerInlineTokens.js +72 -0
- package/dist/shared/composerTrigger.d.ts +26 -0
- package/dist/shared/composerTrigger.js +97 -0
- package/dist/shared/connectAuth.d.ts +58 -0
- package/dist/shared/connectAuth.js +89 -0
- package/dist/shared/devHome.d.ts +21 -0
- package/dist/shared/devHome.js +65 -0
- package/dist/shared/devProxy.d.ts +15 -0
- package/dist/shared/devProxy.js +22 -0
- package/dist/shared/dpop.d.ts +32 -0
- package/dist/shared/dpop.js +2724 -0
- package/dist/shared/dpopCommon.d.ts +2 -0
- package/dist/shared/dpopCommon.js +2 -0
- package/dist/shared/filePreview.d.ts +8 -0
- package/dist/shared/filePreview.js +31 -0
- package/dist/shared/git.d.ts +41 -0
- package/dist/shared/git.js +2 -0
- package/dist/shared/hostProcess.d.ts +13 -0
- package/dist/shared/hostProcess.js +2 -0
- package/dist/shared/httpObservability.d.ts +5 -0
- package/dist/shared/httpObservability.js +2 -0
- package/dist/shared/httpReadiness.d.ts +38 -0
- package/dist/shared/httpReadiness.js +110 -0
- package/dist/shared/keybindings.d.ts +35 -0
- package/dist/shared/keybindings.js +330 -0
- package/dist/shared/logging.d.ts +39 -0
- package/dist/shared/logging.js +2 -0
- package/dist/shared/model.d.ts +44 -0
- package/dist/shared/model.js +2 -0
- package/dist/shared/oauthScope.d.ts +23 -0
- package/dist/shared/oauthScope.js +2 -0
- package/dist/shared/observability.d.ts +105 -0
- package/dist/shared/observability.js +346 -0
- package/dist/shared/orchestrationTiming.d.ts +16 -0
- package/dist/shared/orchestrationTiming.js +32 -0
- package/dist/shared/path.d.ts +2 -0
- package/dist/shared/path.js +2 -0
- package/dist/shared/preview.d.ts +35 -0
- package/dist/shared/preview.js +103 -0
- package/dist/shared/previewViewport.d.ts +16 -0
- package/dist/shared/previewViewport.js +159 -0
- package/dist/shared/projectFavicon.d.ts +5 -0
- package/dist/shared/projectFavicon.js +13 -0
- package/dist/shared/projectScripts.d.ts +19 -0
- package/dist/shared/projectScripts.js +18 -0
- package/dist/shared/qrCode.d.ts +87 -0
- package/dist/shared/qrCode.js +870 -0
- package/dist/shared/relayAuth.d.ts +27 -0
- package/dist/shared/relayAuth.js +83 -0
- package/dist/shared/relayClient.d.ts +58 -0
- package/dist/shared/relayClient.js +245 -0
- package/dist/shared/relayJwt.d.ts +39 -0
- package/dist/shared/relayJwt.js +2 -0
- package/dist/shared/relaySigning.d.ts +4 -0
- package/dist/shared/relaySigning.js +2 -0
- package/dist/shared/relayTracing.d.ts +25 -0
- package/dist/shared/relayTracing.js +2 -0
- package/dist/shared/relayUrl.d.ts +5 -0
- package/dist/shared/relayUrl.js +2 -0
- package/dist/shared/remote.d.ts +57 -0
- package/dist/shared/remote.js +2 -0
- package/dist/shared/schemaJson.d.ts +35 -0
- package/dist/shared/schemaJson.js +2 -0
- package/dist/shared/schemaYaml.d.ts +86 -0
- package/dist/shared/schemaYaml.js +99 -0
- package/dist/shared/searchRanking.d.ts +30 -0
- package/dist/shared/searchRanking.js +99 -0
- package/dist/shared/semver.d.ts +23 -0
- package/dist/shared/semver.js +124 -0
- package/dist/shared/serverSettings.d.ts +19 -0
- package/dist/shared/serverSettings.js +103 -0
- package/dist/shared/shell.d.ts +51 -0
- package/dist/shared/shell.js +408 -0
- package/dist/shared/sourceControl.d.ts +26 -0
- package/dist/shared/sourceControl.js +2 -0
- package/dist/shared/t3ProjectFile.d.ts +27 -0
- package/dist/shared/t3ProjectFile.js +25 -0
- package/dist/shared/terminalLabels.d.ts +16 -0
- package/dist/shared/terminalLabels.js +28 -0
- package/dist/shared/toolActivity.d.ts +16 -0
- package/dist/shared/toolActivity.js +159 -0
- package/dist/shared.d.ts +43036 -0
- package/dist/shared.js +25428 -12277
- package/dist/t3tools.d.ts +2 -0
- package/dist/t3tools.js +1 -1
- package/package.json +39 -21
- package/src/auth/index.ts +2 -0
- package/src/auth/pairing.ts +8 -5
- package/src/auth/service.ts +2 -1
- package/src/auth/transport.ts +4 -0
- package/src/auth/type.ts +6 -0
- package/src/cli/auth.ts +7 -1
- package/src/contracts/index.ts +8 -0
- package/src/orchestration/layer.ts +36 -0
- package/src/orchestration/service.ts +5 -0
- package/src/preview/index.ts +11 -0
- package/src/preview/service.ts +52 -0
- package/src/rpc/error.ts +2 -0
- package/src/rpc/layer.ts +5 -4
- package/src/rpc/operation.ts +5 -4
- package/src/rpc/ws-group.ts +6 -0
- package/src/runtime/index.ts +1 -0
- package/src/runtime/layer.ts +5 -0
- package/src/sql/node-sqlite-client.ts +3 -0
- package/dist/src/application/actions.d.ts +0 -25
- package/dist/src/application/error.d.ts +0 -3
- package/dist/src/application/index.d.ts +0 -4
- package/dist/src/application/layer.d.ts +0 -117
- package/dist/src/application/model-selection.d.ts +0 -34
- package/dist/src/application/models.d.ts +0 -8
- package/dist/src/application/project-commands.d.ts +0 -44
- package/dist/src/application/projects.d.ts +0 -23
- package/dist/src/application/service.d.ts +0 -243
- package/dist/src/application/shell-sequence.d.ts +0 -96
- package/dist/src/application/terminals.d.ts +0 -66
- package/dist/src/application/thread-commands.d.ts +0 -157
- package/dist/src/application/thread-update.d.ts +0 -8
- package/dist/src/application/thread-wait.d.ts +0 -106
- package/dist/src/application/threads.d.ts +0 -660
- package/dist/src/auth/error.d.ts +0 -50
- package/dist/src/auth/index.d.ts +0 -10
- package/dist/src/auth/layer.d.ts +0 -53
- package/dist/src/auth/local-base-dir.d.ts +0 -8
- package/dist/src/auth/local-origin.d.ts +0 -18
- package/dist/src/auth/local-token.d.ts +0 -26
- package/dist/src/auth/local.d.ts +0 -24
- package/dist/src/auth/pairing.d.ts +0 -22
- package/dist/src/auth/remote-error.d.ts +0 -3
- package/dist/src/auth/schema.d.ts +0 -58
- package/dist/src/auth/service.d.ts +0 -27
- package/dist/src/auth/transport.d.ts +0 -22
- package/dist/src/auth/type.d.ts +0 -83
- package/dist/src/cli/env/flag.d.ts +0 -2
- package/dist/src/cli/env/index.d.ts +0 -2
- package/dist/src/cli/env/selection-layer.d.ts +0 -3
- package/dist/src/cli/flags.d.ts +0 -20
- package/dist/src/cli/format/index.d.ts +0 -1
- package/dist/src/cli/format/output.d.ts +0 -12
- package/dist/src/cli/index.d.ts +0 -5
- package/dist/src/cli/runtime/index.d.ts +0 -1
- package/dist/src/cli/runtime/service.d.ts +0 -16
- package/dist/src/cli/scope/index.d.ts +0 -1
- package/dist/src/cli/scope/resolve.d.ts +0 -20
- package/dist/src/cli-path/layer.d.ts +0 -3
- package/dist/src/cli-path/service.d.ts +0 -8
- package/dist/src/config/config.d.ts +0 -49
- package/dist/src/config/credential/cipher-node.d.ts +0 -3
- package/dist/src/config/credential/cipher-web.d.ts +0 -3
- package/dist/src/config/credential/cipher.d.ts +0 -29
- package/dist/src/config/credential/env.d.ts +0 -3
- package/dist/src/config/credential/error.d.ts +0 -8
- package/dist/src/config/credential/index.d.ts +0 -6
- package/dist/src/config/credential/service.d.ts +0 -34
- package/dist/src/config/env/env.d.ts +0 -55
- package/dist/src/config/env/index.d.ts +0 -2
- package/dist/src/config/env/layout.d.ts +0 -11
- package/dist/src/config/environment-name/index.d.ts +0 -1
- package/dist/src/config/environment-name/name.d.ts +0 -10
- package/dist/src/config/error.d.ts +0 -11
- package/dist/src/config/index.d.ts +0 -10
- package/dist/src/config/keystore/error.d.ts +0 -8
- package/dist/src/config/keystore/file.d.ts +0 -9
- package/dist/src/config/keystore/index.d.ts +0 -4
- package/dist/src/config/keystore/keyring-node.d.ts +0 -4
- package/dist/src/config/keystore/service.d.ts +0 -33
- package/dist/src/config/paths/index.d.ts +0 -1
- package/dist/src/config/paths/paths.d.ts +0 -6
- package/dist/src/config/persist/file-mode.d.ts +0 -4
- package/dist/src/config/persist/migration.d.ts +0 -68
- package/dist/src/config/persist/persist.d.ts +0 -40
- package/dist/src/config/persist/schema.d.ts +0 -68
- package/dist/src/config/resolve/resolve.d.ts +0 -40
- package/dist/src/config/selection/index.d.ts +0 -1
- package/dist/src/config/selection/resolve.d.ts +0 -4
- package/dist/src/config/selection/service.d.ts +0 -10
- package/dist/src/config/types.d.ts +0 -36
- package/dist/src/config/url/error.d.ts +0 -10
- package/dist/src/config/url/index.d.ts +0 -2
- package/dist/src/config/url/url.d.ts +0 -6
- package/dist/src/connection/error.d.ts +0 -10
- package/dist/src/connection/index.d.ts +0 -4
- package/dist/src/connection/layer.d.ts +0 -3
- package/dist/src/connection/prepared.d.ts +0 -14
- package/dist/src/connection/service.d.ts +0 -13
- package/dist/src/connection/type.d.ts +0 -10
- package/dist/src/contracts/index.d.ts +0 -1
- package/dist/src/domain/error.d.ts +0 -57
- package/dist/src/domain/helpers.d.ts +0 -179
- package/dist/src/domain/model-config.d.ts +0 -330
- package/dist/src/domain/thread-activities.d.ts +0 -14
- package/dist/src/domain/thread-lifecycle.d.ts +0 -120
- package/dist/src/index.d.ts +0 -3
- package/dist/src/node/connection.d.ts +0 -2
- package/dist/src/node/index.d.ts +0 -1
- package/dist/src/orchestration/index.d.ts +0 -2
- package/dist/src/orchestration/layer.d.ts +0 -1419
- package/dist/src/orchestration/service.d.ts +0 -28
- package/dist/src/rpc/error.d.ts +0 -16
- package/dist/src/rpc/index.d.ts +0 -6
- package/dist/src/rpc/layer.d.ts +0 -5862
- package/dist/src/rpc/operation.d.ts +0 -24
- package/dist/src/rpc/service.d.ts +0 -15
- package/dist/src/rpc/session.d.ts +0 -22
- package/dist/src/rpc/ws-group.d.ts +0 -1984
- package/dist/src/runtime/index.d.ts +0 -1
- package/dist/src/runtime/layer.d.ts +0 -15
- package/dist/src/sql/node-sqlite-client.d.ts +0 -10
- package/dist/src/sql/service.d.ts +0 -17
- package/dist/src/t3tools/index.d.ts +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { A_ as ModelSelection, Cd as ProviderOptionSelection, Kp as ProviderDriverKind, Qp as ProviderInstanceId, _d as ModelCapabilities, xd as ProviderOptionDescriptor } from "../shared.js";
|
|
2
|
+
//#region upstream-t3code/packages/shared/src/model.d.ts
|
|
3
|
+
interface SelectableModelOption {
|
|
4
|
+
slug: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
declare function createModelCapabilities(input: {
|
|
8
|
+
optionDescriptors: ReadonlyArray<ProviderOptionDescriptor>;
|
|
9
|
+
}): ModelCapabilities;
|
|
10
|
+
declare function getProviderOptionSelectionValue(selections: ReadonlyArray<ProviderOptionSelection> | null | undefined, id: string): string | boolean | undefined;
|
|
11
|
+
declare function getProviderOptionStringSelectionValue(selections: ReadonlyArray<ProviderOptionSelection> | null | undefined, id: string): string | undefined;
|
|
12
|
+
declare function getProviderOptionBooleanSelectionValue(selections: ReadonlyArray<ProviderOptionSelection> | null | undefined, id: string): boolean | undefined;
|
|
13
|
+
declare function getModelSelectionOptionValue(modelSelection: ModelSelection | null | undefined, id: string): string | boolean | undefined;
|
|
14
|
+
declare function getModelSelectionStringOptionValue(modelSelection: ModelSelection | null | undefined, id: string): string | undefined;
|
|
15
|
+
declare function getModelSelectionBooleanOptionValue(modelSelection: ModelSelection | null | undefined, id: string): boolean | undefined;
|
|
16
|
+
declare function getProviderOptionDescriptors(input: {
|
|
17
|
+
caps: ModelCapabilities;
|
|
18
|
+
selections?: ReadonlyArray<ProviderOptionSelection> | null | undefined;
|
|
19
|
+
}): ReadonlyArray<ProviderOptionDescriptor>;
|
|
20
|
+
declare function getProviderOptionCurrentValue(descriptor: ProviderOptionDescriptor | null | undefined): string | boolean | undefined;
|
|
21
|
+
declare function getProviderOptionCurrentLabel(descriptor: ProviderOptionDescriptor | null | undefined): string | undefined;
|
|
22
|
+
declare function buildProviderOptionSelectionsFromDescriptors(descriptors: ReadonlyArray<ProviderOptionDescriptor> | null | undefined): Array<ProviderOptionSelection> | undefined;
|
|
23
|
+
declare function getModelSelectionOptionDescriptors(modelSelection: ModelSelection | null | undefined, caps?: ModelCapabilities | null | undefined): ReadonlyArray<ProviderOptionDescriptor>;
|
|
24
|
+
declare function isClaudeUltrathinkPrompt(text: string | null | undefined): boolean;
|
|
25
|
+
declare function normalizeModelSlug(model: string | null | undefined, provider?: ProviderDriverKind): string | null;
|
|
26
|
+
/** Custom model identifiers are provider-owned, so only trim them; never expand aliases. */
|
|
27
|
+
declare function normalizeCustomModelSlug(model: string | null | undefined): string | null;
|
|
28
|
+
declare function resolveSelectableModel(provider: ProviderDriverKind, value: string | null | undefined, options: ReadonlyArray<SelectableModelOption>): string | null;
|
|
29
|
+
declare function resolveModelSlugForProvider(provider: ProviderDriverKind, model: string | null | undefined): string;
|
|
30
|
+
/** Trim a string, returning null for empty/missing values. */
|
|
31
|
+
declare function trimOrNull<T extends string>(value: T | null | undefined): T | null;
|
|
32
|
+
declare function createModelSelection(instanceId: ProviderInstanceId, model: string, options?: ReadonlyArray<ProviderOptionSelection> | null): ModelSelection;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the effort value if it is a prompt-injected value according to
|
|
35
|
+
* any select descriptor in the given capabilities, or null otherwise.
|
|
36
|
+
*
|
|
37
|
+
* Unlike a single `find`, this checks every descriptor so that the
|
|
38
|
+
* correct descriptor's `promptInjectedValues` list is consulted even when
|
|
39
|
+
* multiple select descriptors exist.
|
|
40
|
+
*/
|
|
41
|
+
declare function resolvePromptInjectedEffort(caps: ModelCapabilities, rawEffort: string | null | undefined): string | null;
|
|
42
|
+
declare function applyClaudePromptEffortPrefix(text: string, effort: string | null | undefined): string;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { SelectableModelOption, applyClaudePromptEffortPrefix, buildProviderOptionSelectionsFromDescriptors, createModelCapabilities, createModelSelection, getModelSelectionBooleanOptionValue, getModelSelectionOptionDescriptors, getModelSelectionOptionValue, getModelSelectionStringOptionValue, getProviderOptionBooleanSelectionValue, getProviderOptionCurrentLabel, getProviderOptionCurrentValue, getProviderOptionDescriptors, getProviderOptionSelectionValue, getProviderOptionStringSelectionValue, isClaudeUltrathinkPrompt, normalizeCustomModelSlug, normalizeModelSlug, resolveModelSlugForProvider, resolvePromptInjectedEffort, resolveSelectableModel, trimOrNull };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as applyClaudePromptEffortPrefix, B as getProviderOptionCurrentValue, F as getModelSelectionOptionDescriptors, G as normalizeCustomModelSlug, H as getProviderOptionSelectionValue, I as getModelSelectionOptionValue, J as resolvePromptInjectedEffort, K as normalizeModelSlug, L as getModelSelectionStringOptionValue, M as createModelCapabilities, N as createModelSelection, P as getModelSelectionBooleanOptionValue, R as getProviderOptionBooleanSelectionValue, U as getProviderOptionStringSelectionValue, V as getProviderOptionDescriptors, W as isClaudeUltrathinkPrompt, X as trimOrNull, Y as resolveSelectableModel, j as buildProviderOptionSelectionsFromDescriptors, q as resolveModelSlugForProvider, z as getProviderOptionCurrentLabel } from "../shared.js";
|
|
2
|
+
export { applyClaudePromptEffortPrefix, buildProviderOptionSelectionsFromDescriptors, createModelCapabilities, createModelSelection, getModelSelectionBooleanOptionValue, getModelSelectionOptionDescriptors, getModelSelectionOptionValue, getModelSelectionStringOptionValue, getProviderOptionBooleanSelectionValue, getProviderOptionCurrentLabel, getProviderOptionCurrentValue, getProviderOptionDescriptors, getProviderOptionSelectionValue, getProviderOptionStringSelectionValue, isClaudeUltrathinkPrompt, normalizeCustomModelSlug, normalizeModelSlug, resolveModelSlugForProvider, resolvePromptInjectedEffort, resolveSelectableModel, trimOrNull };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
//#region upstream-t3code/packages/shared/src/oauthScope.d.ts
|
|
3
|
+
declare const OAuthScopeEncodingError_base: Schema.Class<OAuthScopeEncodingError, Schema.TaggedStruct<"OAuthScopeEncodingError", {
|
|
4
|
+
readonly scopes: Schema.$Array<Schema.String>;
|
|
5
|
+
readonly invalidScopes: Schema.$Array<Schema.String>;
|
|
6
|
+
readonly duplicateScopes: Schema.$Array<Schema.String>;
|
|
7
|
+
}>, import("effect/Cause").YieldableError>;
|
|
8
|
+
declare class OAuthScopeEncodingError extends OAuthScopeEncodingError_base {
|
|
9
|
+
get message(): string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Decodes an RFC 6749 `scope` value as a set while preserving its first-seen
|
|
13
|
+
* order for canonical responses and logs.
|
|
14
|
+
*/
|
|
15
|
+
declare function parseOAuthScope(value: string): ReadonlyArray<string> | null;
|
|
16
|
+
declare function encodeOAuthScope(scopes: ReadonlyArray<string>): string;
|
|
17
|
+
declare function oauthScopeSetEquals(value: string, expectedScopes: ReadonlyArray<string>): boolean;
|
|
18
|
+
declare function parseAllowedOAuthScope<Scope extends string>(input: {
|
|
19
|
+
readonly value: string;
|
|
20
|
+
readonly allowedScopes: ReadonlySet<Scope>;
|
|
21
|
+
}): ReadonlyArray<Scope> | null;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { OAuthScopeEncodingError, encodeOAuthScope, oauthScopeSetEquals, parseAllowedOAuthScope, parseOAuthScope };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Go as parseOAuthScope, Ho as encodeOAuthScope, Uo as oauthScopeSetEquals, Vo as OAuthScopeEncodingError, Wo as parseAllowedOAuthScope } from "../shared.js";
|
|
2
|
+
export { OAuthScopeEncodingError, encodeOAuthScope, oauthScopeSetEquals, parseAllowedOAuthScope, parseOAuthScope };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import * as Cause from "effect/Cause";
|
|
4
|
+
import * as Tracer from "effect/Tracer";
|
|
5
|
+
import { OtlpTracer } from "effect/unstable/observability";
|
|
6
|
+
//#region upstream-t3code/packages/shared/src/observability.d.ts
|
|
7
|
+
type TraceAttributes = Readonly<Record<string, unknown>>;
|
|
8
|
+
interface TraceRecordEvent {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly timeUnixNano: string;
|
|
11
|
+
readonly attributes: Readonly<Record<string, unknown>>;
|
|
12
|
+
}
|
|
13
|
+
interface TraceRecordLink {
|
|
14
|
+
readonly traceId: string;
|
|
15
|
+
readonly spanId: string;
|
|
16
|
+
readonly attributes: Readonly<Record<string, unknown>>;
|
|
17
|
+
}
|
|
18
|
+
interface BaseTraceRecord {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly kind: string;
|
|
21
|
+
readonly traceId: string;
|
|
22
|
+
readonly spanId: string;
|
|
23
|
+
readonly parentSpanId?: string;
|
|
24
|
+
readonly sampled: boolean;
|
|
25
|
+
readonly startTimeUnixNano: string;
|
|
26
|
+
readonly endTimeUnixNano: string;
|
|
27
|
+
readonly durationMs: number;
|
|
28
|
+
readonly attributes: Readonly<Record<string, unknown>>;
|
|
29
|
+
readonly events: ReadonlyArray<TraceRecordEvent>;
|
|
30
|
+
readonly links: ReadonlyArray<TraceRecordLink>;
|
|
31
|
+
}
|
|
32
|
+
interface EffectTraceRecord extends BaseTraceRecord {
|
|
33
|
+
readonly type: "effect-span";
|
|
34
|
+
readonly exit: {
|
|
35
|
+
readonly _tag: "Success";
|
|
36
|
+
} | {
|
|
37
|
+
readonly _tag: "Interrupted";
|
|
38
|
+
readonly cause: string;
|
|
39
|
+
} | {
|
|
40
|
+
readonly _tag: "Failure";
|
|
41
|
+
readonly cause: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
interface OtlpTraceRecord extends BaseTraceRecord {
|
|
45
|
+
readonly type: "otlp-span";
|
|
46
|
+
readonly resourceAttributes: Readonly<Record<string, unknown>>;
|
|
47
|
+
readonly scope: Readonly<{
|
|
48
|
+
readonly name?: string;
|
|
49
|
+
readonly version?: string;
|
|
50
|
+
readonly attributes: Readonly<Record<string, unknown>>;
|
|
51
|
+
}>;
|
|
52
|
+
readonly status?: {
|
|
53
|
+
readonly code?: string;
|
|
54
|
+
readonly message?: string;
|
|
55
|
+
} | undefined;
|
|
56
|
+
}
|
|
57
|
+
type TraceRecord = EffectTraceRecord | OtlpTraceRecord;
|
|
58
|
+
declare function errorTag(error: unknown): string;
|
|
59
|
+
declare function causeErrorTag(cause: Cause.Cause<unknown>): string;
|
|
60
|
+
interface TraceSinkOptions {
|
|
61
|
+
readonly filePath: string;
|
|
62
|
+
readonly maxBytes: number;
|
|
63
|
+
readonly maxFiles: number;
|
|
64
|
+
readonly batchWindowMs: number;
|
|
65
|
+
readonly onFlush?: (stats: TraceSinkFlushStats) => Effect.Effect<void>;
|
|
66
|
+
}
|
|
67
|
+
interface TraceSinkFlushStats {
|
|
68
|
+
readonly logicalWriteBytes: number;
|
|
69
|
+
readonly count: number;
|
|
70
|
+
readonly durationMs: number;
|
|
71
|
+
}
|
|
72
|
+
interface TraceSink {
|
|
73
|
+
readonly filePath: string;
|
|
74
|
+
push: (record: TraceRecord) => void;
|
|
75
|
+
flush: Effect.Effect<void>;
|
|
76
|
+
close: () => Effect.Effect<void>;
|
|
77
|
+
}
|
|
78
|
+
interface LocalFileTracerOptions extends TraceSinkOptions {
|
|
79
|
+
readonly delegate?: Tracer.Tracer;
|
|
80
|
+
readonly sink?: TraceSink;
|
|
81
|
+
}
|
|
82
|
+
interface SerializableSpan {
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly traceId: string;
|
|
85
|
+
readonly spanId: string;
|
|
86
|
+
readonly parent: Option.Option<Tracer.AnySpan>;
|
|
87
|
+
readonly status: Tracer.SpanStatus;
|
|
88
|
+
readonly sampled: boolean;
|
|
89
|
+
readonly kind: Tracer.SpanKind;
|
|
90
|
+
readonly attributes: ReadonlyMap<string, unknown>;
|
|
91
|
+
readonly links: ReadonlyArray<Tracer.SpanLink>;
|
|
92
|
+
readonly events: ReadonlyArray<readonly [name: string, startTime: bigint, attributes: Record<string, unknown>]>;
|
|
93
|
+
}
|
|
94
|
+
declare function compactTraceAttributes(attributes: Readonly<Record<string, unknown>>): TraceAttributes;
|
|
95
|
+
declare function spanToTraceRecord(span: SerializableSpan): EffectTraceRecord;
|
|
96
|
+
declare const makeTraceSink: (options: TraceSinkOptions) => Effect.Effect<{
|
|
97
|
+
filePath: string;
|
|
98
|
+
push(record: TraceRecord): void;
|
|
99
|
+
flush: Effect.Effect<void, never, never>;
|
|
100
|
+
close: () => Effect.Effect<void, never, never>;
|
|
101
|
+
}, never, import("effect/Scope").Scope>;
|
|
102
|
+
declare const makeLocalFileTracer: (options: LocalFileTracerOptions) => Effect.Effect<Tracer.Tracer, never, import("effect/Scope").Scope>;
|
|
103
|
+
declare function decodeOtlpTraceRecords(payload: OtlpTracer.TraceData): ReadonlyArray<OtlpTraceRecord>;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { EffectTraceRecord, LocalFileTracerOptions, OtlpTraceRecord, TraceAttributes, TraceRecord, TraceRecordEvent, TraceRecordLink, TraceSink, TraceSinkFlushStats, TraceSinkOptions, causeErrorTag, compactTraceAttributes, decodeOtlpTraceRecords, errorTag, makeLocalFileTracer, makeTraceSink, spanToTraceRecord };
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { $D as flatMap, BD as andThen, Bk as isSome, D as RotatingFileSink, JO as findErrorOption, OO as sync, RD as addFinalizer, RO as void_, Rk as getOrUndefined, TO as sleep, XO as pretty, YO as hasInterruptsOnly, dk as isSuccess, eO as fn, iO as forkScoped, mk as make, oO as ignore, pk as NativeSpan, rO as forever, zO as withTracerEnabled } from "../shared.js";
|
|
2
|
+
//#region upstream-t3code/packages/shared/src/observability.ts
|
|
3
|
+
const FLUSH_BUFFER_THRESHOLD = 256;
|
|
4
|
+
const textEncoder = new TextEncoder();
|
|
5
|
+
function isStructuralTag(value) {
|
|
6
|
+
return typeof value === "string" && value.length > 0 && value.length <= 128 && /^[A-Za-z][A-Za-z0-9._:/-]*$/.test(value);
|
|
7
|
+
}
|
|
8
|
+
function errorTag(error) {
|
|
9
|
+
try {
|
|
10
|
+
if (typeof error === "object" && error !== null && "_tag" in error) return isStructuralTag(error._tag) ? error._tag : "TaggedError";
|
|
11
|
+
if (error instanceof Error) return isStructuralTag(error.name) ? error.name : "Error";
|
|
12
|
+
} catch {
|
|
13
|
+
return "UnknownError";
|
|
14
|
+
}
|
|
15
|
+
return typeof error;
|
|
16
|
+
}
|
|
17
|
+
function causeErrorTag(cause) {
|
|
18
|
+
const failure = findErrorOption(cause);
|
|
19
|
+
if (isSome(failure)) return errorTag(failure.value);
|
|
20
|
+
return cause.reasons[0]?._tag ?? "Empty";
|
|
21
|
+
}
|
|
22
|
+
function isPlainObject(value) {
|
|
23
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
|
+
}
|
|
25
|
+
function markSeen(value, seen) {
|
|
26
|
+
if (seen.has(value)) return true;
|
|
27
|
+
seen.add(value);
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
function normalizeJsonValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
31
|
+
if (value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value ?? null;
|
|
32
|
+
if (typeof value === "bigint") return value.toString();
|
|
33
|
+
if (value instanceof Date) return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
|
|
34
|
+
if (value instanceof Error) return {
|
|
35
|
+
name: value.name,
|
|
36
|
+
message: value.message,
|
|
37
|
+
...value.stack ? { stack: value.stack } : {}
|
|
38
|
+
};
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
if (markSeen(value, seen)) return "[Circular]";
|
|
41
|
+
return value.map((entry) => normalizeJsonValue(entry, seen));
|
|
42
|
+
}
|
|
43
|
+
if (value instanceof Map) {
|
|
44
|
+
if (markSeen(value, seen)) return "[Circular]";
|
|
45
|
+
return Object.fromEntries(Array.from(value.entries(), ([key, entryValue]) => [String(key), normalizeJsonValue(entryValue, seen)]));
|
|
46
|
+
}
|
|
47
|
+
if (value instanceof Set) {
|
|
48
|
+
if (markSeen(value, seen)) return "[Circular]";
|
|
49
|
+
return Array.from(value.values(), (entry) => normalizeJsonValue(entry, seen));
|
|
50
|
+
}
|
|
51
|
+
if (!isPlainObject(value)) return String(value);
|
|
52
|
+
if (markSeen(value, seen)) return "[Circular]";
|
|
53
|
+
return Object.fromEntries(Object.entries(value).map(([key, entryValue]) => [key, normalizeJsonValue(entryValue, seen)]));
|
|
54
|
+
}
|
|
55
|
+
function compactTraceAttributes(attributes) {
|
|
56
|
+
const entries = [];
|
|
57
|
+
for (const [key, value] of Object.entries(attributes)) if (value !== void 0) entries.push([key, normalizeJsonValue(value)]);
|
|
58
|
+
return Object.fromEntries(entries);
|
|
59
|
+
}
|
|
60
|
+
function formatTraceExit(exit) {
|
|
61
|
+
if (isSuccess(exit)) return { _tag: "Success" };
|
|
62
|
+
if (hasInterruptsOnly(exit.cause)) return {
|
|
63
|
+
_tag: "Interrupted",
|
|
64
|
+
cause: pretty(exit.cause)
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
_tag: "Failure",
|
|
68
|
+
cause: pretty(exit.cause)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function spanToTraceRecord(span) {
|
|
72
|
+
const status = span.status;
|
|
73
|
+
const parentSpanId = getOrUndefined(span.parent)?.spanId;
|
|
74
|
+
return {
|
|
75
|
+
type: "effect-span",
|
|
76
|
+
name: span.name,
|
|
77
|
+
traceId: span.traceId,
|
|
78
|
+
spanId: span.spanId,
|
|
79
|
+
...parentSpanId ? { parentSpanId } : {},
|
|
80
|
+
sampled: span.sampled,
|
|
81
|
+
kind: span.kind,
|
|
82
|
+
startTimeUnixNano: String(status.startTime),
|
|
83
|
+
endTimeUnixNano: String(status.endTime),
|
|
84
|
+
durationMs: Number(status.endTime - status.startTime) / 1e6,
|
|
85
|
+
attributes: compactTraceAttributes(Object.fromEntries(span.attributes)),
|
|
86
|
+
events: span.events.map(([name, startTime, attributes]) => ({
|
|
87
|
+
name,
|
|
88
|
+
timeUnixNano: String(startTime),
|
|
89
|
+
attributes: compactTraceAttributes(attributes)
|
|
90
|
+
})),
|
|
91
|
+
links: span.links.map((link) => ({
|
|
92
|
+
traceId: link.span.traceId,
|
|
93
|
+
spanId: link.span.spanId,
|
|
94
|
+
attributes: compactTraceAttributes(link.attributes)
|
|
95
|
+
})),
|
|
96
|
+
exit: formatTraceExit(status.exit)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const makeTraceSink = fn("makeTraceSink")(function* (options) {
|
|
100
|
+
const sink = new RotatingFileSink({
|
|
101
|
+
filePath: options.filePath,
|
|
102
|
+
maxBytes: options.maxBytes,
|
|
103
|
+
maxFiles: options.maxFiles,
|
|
104
|
+
throwOnError: true
|
|
105
|
+
});
|
|
106
|
+
let buffer = [];
|
|
107
|
+
let pendingFlushStats = {
|
|
108
|
+
logicalWriteBytes: 0,
|
|
109
|
+
count: 0,
|
|
110
|
+
durationMs: 0
|
|
111
|
+
};
|
|
112
|
+
const flushUnsafe = () => {
|
|
113
|
+
if (buffer.length === 0) return;
|
|
114
|
+
const records = buffer;
|
|
115
|
+
buffer = [];
|
|
116
|
+
let persistedCount = 0;
|
|
117
|
+
while (persistedCount < records.length) {
|
|
118
|
+
const firstRecordBytes = textEncoder.encode(records[persistedCount]).byteLength;
|
|
119
|
+
if (firstRecordBytes > options.maxBytes) {
|
|
120
|
+
persistedCount += 1;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
let nextIndex = persistedCount + 1;
|
|
124
|
+
let chunkBytes = firstRecordBytes;
|
|
125
|
+
while (nextIndex < records.length) {
|
|
126
|
+
const nextRecordBytes = textEncoder.encode(records[nextIndex]).byteLength;
|
|
127
|
+
if (chunkBytes + nextRecordBytes > options.maxBytes) break;
|
|
128
|
+
chunkBytes += nextRecordBytes;
|
|
129
|
+
nextIndex += 1;
|
|
130
|
+
}
|
|
131
|
+
const chunk = records.slice(persistedCount, nextIndex).join("");
|
|
132
|
+
const startedAt = performance.now();
|
|
133
|
+
try {
|
|
134
|
+
sink.write(chunk);
|
|
135
|
+
} catch {
|
|
136
|
+
buffer.unshift(...records.slice(persistedCount));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
pendingFlushStats = {
|
|
140
|
+
logicalWriteBytes: pendingFlushStats.logicalWriteBytes + chunkBytes,
|
|
141
|
+
count: pendingFlushStats.count + nextIndex - persistedCount,
|
|
142
|
+
durationMs: pendingFlushStats.durationMs + Math.max(0, performance.now() - startedAt)
|
|
143
|
+
};
|
|
144
|
+
persistedCount = nextIndex;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const flush = sync(() => {
|
|
148
|
+
flushUnsafe();
|
|
149
|
+
const stats = pendingFlushStats;
|
|
150
|
+
pendingFlushStats = {
|
|
151
|
+
logicalWriteBytes: 0,
|
|
152
|
+
count: 0,
|
|
153
|
+
durationMs: 0
|
|
154
|
+
};
|
|
155
|
+
return stats;
|
|
156
|
+
}).pipe(flatMap((stats) => stats.count > 0 && options.onFlush ? options.onFlush(stats).pipe(ignore) : void_), withTracerEnabled(false));
|
|
157
|
+
yield* addFinalizer(() => flush.pipe(ignore));
|
|
158
|
+
yield* forkScoped(sleep(`${options.batchWindowMs} millis`).pipe(andThen(flush), forever));
|
|
159
|
+
return {
|
|
160
|
+
filePath: options.filePath,
|
|
161
|
+
push(record) {
|
|
162
|
+
try {
|
|
163
|
+
buffer.push(`${JSON.stringify(record)}\n`);
|
|
164
|
+
if (buffer.length >= FLUSH_BUFFER_THRESHOLD) flushUnsafe();
|
|
165
|
+
} catch {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
flush,
|
|
170
|
+
close: () => flush
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
var LocalFileSpan = class {
|
|
174
|
+
_tag = "Span";
|
|
175
|
+
name;
|
|
176
|
+
spanId;
|
|
177
|
+
traceId;
|
|
178
|
+
parent;
|
|
179
|
+
annotations;
|
|
180
|
+
links;
|
|
181
|
+
sampled;
|
|
182
|
+
kind;
|
|
183
|
+
status;
|
|
184
|
+
attributes;
|
|
185
|
+
events;
|
|
186
|
+
delegate;
|
|
187
|
+
push;
|
|
188
|
+
constructor(options, delegate, push) {
|
|
189
|
+
this.delegate = delegate;
|
|
190
|
+
this.push = push;
|
|
191
|
+
this.name = delegate.name;
|
|
192
|
+
this.spanId = delegate.spanId;
|
|
193
|
+
this.traceId = delegate.traceId;
|
|
194
|
+
this.parent = options.parent;
|
|
195
|
+
this.annotations = options.annotations;
|
|
196
|
+
this.links = [...options.links];
|
|
197
|
+
this.sampled = delegate.sampled;
|
|
198
|
+
this.kind = delegate.kind;
|
|
199
|
+
this.status = {
|
|
200
|
+
_tag: "Started",
|
|
201
|
+
startTime: options.startTime
|
|
202
|
+
};
|
|
203
|
+
this.attributes = /* @__PURE__ */ new Map();
|
|
204
|
+
this.events = [];
|
|
205
|
+
}
|
|
206
|
+
end(endTime, exit) {
|
|
207
|
+
this.status = {
|
|
208
|
+
_tag: "Ended",
|
|
209
|
+
startTime: this.status.startTime,
|
|
210
|
+
endTime,
|
|
211
|
+
exit
|
|
212
|
+
};
|
|
213
|
+
this.delegate.end(endTime, exit);
|
|
214
|
+
if (this.sampled) this.push(spanToTraceRecord(this));
|
|
215
|
+
}
|
|
216
|
+
attribute(key, value) {
|
|
217
|
+
this.attributes.set(key, value);
|
|
218
|
+
this.delegate.attribute(key, value);
|
|
219
|
+
}
|
|
220
|
+
event(name, startTime, attributes) {
|
|
221
|
+
const nextAttributes = attributes ?? {};
|
|
222
|
+
this.events.push([
|
|
223
|
+
name,
|
|
224
|
+
startTime,
|
|
225
|
+
nextAttributes
|
|
226
|
+
]);
|
|
227
|
+
this.delegate.event(name, startTime, nextAttributes);
|
|
228
|
+
}
|
|
229
|
+
addLinks(links) {
|
|
230
|
+
this.links.push(...links);
|
|
231
|
+
this.delegate.addLinks(links);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const makeLocalFileTracer = fn("makeLocalFileTracer")(function* (options) {
|
|
235
|
+
const sink = options.sink ?? (yield* makeTraceSink({
|
|
236
|
+
filePath: options.filePath,
|
|
237
|
+
maxBytes: options.maxBytes,
|
|
238
|
+
maxFiles: options.maxFiles,
|
|
239
|
+
batchWindowMs: options.batchWindowMs,
|
|
240
|
+
...options.onFlush ? { onFlush: options.onFlush } : {}
|
|
241
|
+
}));
|
|
242
|
+
const delegate = options.delegate ?? make({ span: (spanOptions) => new NativeSpan(spanOptions) });
|
|
243
|
+
return make({
|
|
244
|
+
span(spanOptions) {
|
|
245
|
+
return new LocalFileSpan(spanOptions, delegate.span(spanOptions), sink.push);
|
|
246
|
+
},
|
|
247
|
+
...delegate.context ? { context: delegate.context } : {}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
const SPAN_KIND_MAP = {
|
|
251
|
+
1: "internal",
|
|
252
|
+
2: "server",
|
|
253
|
+
3: "client",
|
|
254
|
+
4: "producer",
|
|
255
|
+
5: "consumer"
|
|
256
|
+
};
|
|
257
|
+
function decodeOtlpTraceRecords(payload) {
|
|
258
|
+
const records = [];
|
|
259
|
+
for (const resourceSpan of payload.resourceSpans) {
|
|
260
|
+
const resourceAttributes = decodeAttributes(resourceSpan.resource?.attributes ?? []);
|
|
261
|
+
for (const scopeSpan of resourceSpan.scopeSpans) for (const span of scopeSpan.spans) records.push(otlpSpanToTraceRecord({
|
|
262
|
+
resourceAttributes,
|
|
263
|
+
scopeAttributes: decodeAttributes("attributes" in scopeSpan.scope && Array.isArray(scopeSpan.scope.attributes) ? scopeSpan.scope.attributes : []),
|
|
264
|
+
scopeName: scopeSpan.scope.name,
|
|
265
|
+
scopeVersion: "version" in scopeSpan.scope && typeof scopeSpan.scope.version === "string" ? scopeSpan.scope.version : void 0,
|
|
266
|
+
span
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
return records;
|
|
270
|
+
}
|
|
271
|
+
function otlpSpanToTraceRecord(input) {
|
|
272
|
+
return {
|
|
273
|
+
type: "otlp-span",
|
|
274
|
+
name: input.span.name,
|
|
275
|
+
traceId: input.span.traceId,
|
|
276
|
+
spanId: input.span.spanId,
|
|
277
|
+
...input.span.parentSpanId ? { parentSpanId: input.span.parentSpanId } : {},
|
|
278
|
+
sampled: true,
|
|
279
|
+
kind: normalizeSpanKind(input.span.kind),
|
|
280
|
+
startTimeUnixNano: input.span.startTimeUnixNano,
|
|
281
|
+
endTimeUnixNano: input.span.endTimeUnixNano,
|
|
282
|
+
durationMs: Number(parseBigInt(input.span.endTimeUnixNano) - parseBigInt(input.span.startTimeUnixNano)) / 1e6,
|
|
283
|
+
attributes: decodeAttributes(input.span.attributes),
|
|
284
|
+
resourceAttributes: input.resourceAttributes,
|
|
285
|
+
scope: {
|
|
286
|
+
...input.scopeName ? { name: input.scopeName } : {},
|
|
287
|
+
...input.scopeVersion ? { version: input.scopeVersion } : {},
|
|
288
|
+
attributes: input.scopeAttributes
|
|
289
|
+
},
|
|
290
|
+
events: decodeEvents(input.span.events),
|
|
291
|
+
links: decodeLinks(input.span.links),
|
|
292
|
+
status: decodeStatus(input.span.status)
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function decodeStatus(input) {
|
|
296
|
+
const code = String(input.code);
|
|
297
|
+
const message = input.message;
|
|
298
|
+
return {
|
|
299
|
+
code,
|
|
300
|
+
...message ? { message } : {}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function decodeEvents(input) {
|
|
304
|
+
return input.map((current) => ({
|
|
305
|
+
name: current.name,
|
|
306
|
+
timeUnixNano: current.timeUnixNano,
|
|
307
|
+
attributes: decodeAttributes(current.attributes)
|
|
308
|
+
}));
|
|
309
|
+
}
|
|
310
|
+
function decodeLinks(input) {
|
|
311
|
+
return input.flatMap((current) => {
|
|
312
|
+
return {
|
|
313
|
+
traceId: current.traceId,
|
|
314
|
+
spanId: current.spanId,
|
|
315
|
+
attributes: decodeAttributes(current.attributes)
|
|
316
|
+
};
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function decodeAttributes(input) {
|
|
320
|
+
const entries = {};
|
|
321
|
+
for (const attribute of input) entries[attribute.key] = decodeValue(attribute.value);
|
|
322
|
+
return compactTraceAttributes(entries);
|
|
323
|
+
}
|
|
324
|
+
function decodeValue(input) {
|
|
325
|
+
if (input == null) return null;
|
|
326
|
+
if ("stringValue" in input) return input.stringValue;
|
|
327
|
+
if ("boolValue" in input) return input.boolValue;
|
|
328
|
+
if ("intValue" in input) return input.intValue;
|
|
329
|
+
if ("doubleValue" in input) return input.doubleValue;
|
|
330
|
+
if ("bytesValue" in input) return input.bytesValue;
|
|
331
|
+
if (input.arrayValue) return input.arrayValue.values.map((entry) => decodeValue(entry));
|
|
332
|
+
if (input.kvlistValue) return decodeAttributes(input.kvlistValue.values);
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
function normalizeSpanKind(input) {
|
|
336
|
+
return SPAN_KIND_MAP[input] || "internal";
|
|
337
|
+
}
|
|
338
|
+
function parseBigInt(input) {
|
|
339
|
+
try {
|
|
340
|
+
return BigInt(input);
|
|
341
|
+
} catch {
|
|
342
|
+
return 0n;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
export { causeErrorTag, compactTraceAttributes, decodeOtlpTraceRecords, errorTag, makeLocalFileTracer, makeTraceSink, spanToTraceRecord };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region upstream-t3code/packages/shared/src/orchestrationTiming.d.ts
|
|
2
|
+
type LatestTurnTiming = {
|
|
3
|
+
readonly turnId: string | null;
|
|
4
|
+
readonly startedAt: string | null;
|
|
5
|
+
readonly completedAt: string | null;
|
|
6
|
+
};
|
|
7
|
+
type SessionActivityState = {
|
|
8
|
+
readonly orchestrationStatus: string;
|
|
9
|
+
readonly activeTurnId?: string | null;
|
|
10
|
+
};
|
|
11
|
+
declare function formatDuration(durationMs: number): string;
|
|
12
|
+
declare function formatElapsed(startIso: string, endIso: string | undefined): string | null;
|
|
13
|
+
declare function isLatestTurnSettled(latestTurn: LatestTurnTiming | null, session: SessionActivityState | null): boolean;
|
|
14
|
+
declare function deriveActiveWorkStartedAt(latestTurn: LatestTurnTiming | null, session: SessionActivityState | null, sendStartedAt: string | null): string | null;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { deriveActiveWorkStartedAt, formatDuration, formatElapsed, isLatestTurnSettled };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region upstream-t3code/packages/shared/src/orchestrationTiming.ts
|
|
2
|
+
function formatDuration(durationMs) {
|
|
3
|
+
if (!Number.isFinite(durationMs) || durationMs < 0) return "0ms";
|
|
4
|
+
if (durationMs < 1e3) return `${Math.max(1, Math.round(durationMs))}ms`;
|
|
5
|
+
if (durationMs < 1e4) return `${(durationMs / 1e3).toFixed(1)}s`;
|
|
6
|
+
if (durationMs < 6e4) return `${Math.round(durationMs / 1e3)}s`;
|
|
7
|
+
const minutes = Math.floor(durationMs / 6e4);
|
|
8
|
+
const seconds = Math.round(durationMs % 6e4 / 1e3);
|
|
9
|
+
if (seconds === 0) return `${minutes}m`;
|
|
10
|
+
if (seconds === 60) return `${minutes + 1}m`;
|
|
11
|
+
return `${minutes}m ${seconds}s`;
|
|
12
|
+
}
|
|
13
|
+
function formatElapsed(startIso, endIso) {
|
|
14
|
+
if (!endIso) return null;
|
|
15
|
+
const startedAt = Date.parse(startIso);
|
|
16
|
+
const endedAt = Date.parse(endIso);
|
|
17
|
+
if (Number.isNaN(startedAt) || Number.isNaN(endedAt) || endedAt < startedAt) return null;
|
|
18
|
+
return formatDuration(endedAt - startedAt);
|
|
19
|
+
}
|
|
20
|
+
function isLatestTurnSettled(latestTurn, session) {
|
|
21
|
+
if (!latestTurn?.startedAt) return false;
|
|
22
|
+
if (!latestTurn.completedAt) return false;
|
|
23
|
+
if (!session) return true;
|
|
24
|
+
if (session.orchestrationStatus === "running") return false;
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
function deriveActiveWorkStartedAt(latestTurn, session, sendStartedAt) {
|
|
28
|
+
if (!isLatestTurnSettled(latestTurn, session)) return latestTurn?.startedAt ?? sendStartedAt;
|
|
29
|
+
return sendStartedAt;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { deriveActiveWorkStartedAt, formatDuration, formatElapsed, isLatestTurnSettled };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as isWindowsAbsolutePath, c as normalizeProjectPathForDispatch, i as isUncPath, o as isWindowsDrivePath, r as isExplicitRelativePath, s as normalizeProjectPathForComparison } from "../shared.js";
|
|
2
|
+
export { isExplicitRelativePath, isUncPath, isWindowsAbsolutePath, isWindowsDrivePath, normalizeProjectPathForComparison, normalizeProjectPathForDispatch };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { an as isUncPath, cn as normalizeProjectPathForComparison, in as isExplicitRelativePath, ln as normalizeProjectPathForDispatch, on as isWindowsAbsolutePath, sn as isWindowsDrivePath } from "../shared.js";
|
|
2
|
+
export { isExplicitRelativePath, isUncPath, isWindowsAbsolutePath, isWindowsDrivePath, normalizeProjectPathForComparison, normalizeProjectPathForDispatch };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
//#region upstream-t3code/packages/shared/src/preview.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Generate a fresh preview tab id. Lives in shared (not contracts) because
|
|
5
|
+
* the contracts package is schema-only — runtime helpers belong here.
|
|
6
|
+
*/
|
|
7
|
+
declare function newPreviewTabId(): string;
|
|
8
|
+
/** Internal — used by `lsof` parsing where the host string is wire-formatted. */
|
|
9
|
+
declare const LSOF_LOCAL_HOST_TOKENS: ReadonlySet<string>;
|
|
10
|
+
declare function isLoopbackHost(host: string): boolean;
|
|
11
|
+
/** True when a raw URL string looks like a loopback dev URL we can preview. */
|
|
12
|
+
declare function isPreviewableUrl(rawUrl: string): boolean;
|
|
13
|
+
declare const PreviewUrlNormalizationError_base: Schema.Class<PreviewUrlNormalizationError, Schema.TaggedStruct<"PreviewUrlNormalizationError", {
|
|
14
|
+
readonly inputLength: Schema.Number;
|
|
15
|
+
readonly reason: Schema.Literals<readonly ["empty", "parse", "unsupported-protocol"]>;
|
|
16
|
+
readonly protocol: Schema.optional<Schema.String>;
|
|
17
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
18
|
+
}>, import("effect/Cause").YieldableError>;
|
|
19
|
+
declare class PreviewUrlNormalizationError extends PreviewUrlNormalizationError_base {
|
|
20
|
+
get message(): string;
|
|
21
|
+
}
|
|
22
|
+
declare const isPreviewUrlNormalizationError: <I>(input: I) => input is I & PreviewUrlNormalizationError;
|
|
23
|
+
/**
|
|
24
|
+
* Normalise a free-form URL string into a fully-qualified `http(s)://` URL.
|
|
25
|
+
*
|
|
26
|
+
* - Bare loopback hosts (`localhost`, `localhost:5173`) become `http://...`.
|
|
27
|
+
* - Bare public hosts (`example.com`) become `https://...`.
|
|
28
|
+
* - Already-qualified URLs are validated and returned as `URL.href`.
|
|
29
|
+
*
|
|
30
|
+
* Throws `PreviewUrlNormalizationError` for empty, unparseable, or
|
|
31
|
+
* unsupported-protocol inputs.
|
|
32
|
+
*/
|
|
33
|
+
declare function normalizePreviewUrl(rawUrl: string): string;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { LSOF_LOCAL_HOST_TOKENS, PreviewUrlNormalizationError, isLoopbackHost, isPreviewUrlNormalizationError, isPreviewableUrl, newPreviewTabId, normalizePreviewUrl };
|