oh-my-opencode 5.0.0-beta.82 → 5.0.0-beta.83
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.ja.md +2 -2
- package/README.ko.md +2 -2
- package/README.md +4 -4
- package/README.ru.md +2 -2
- package/README.zh-cn.md +2 -2
- package/dist/cli/index.js +392 -112
- package/dist/cli/install-native/index.d.ts +4 -0
- package/dist/cli/install-native/plan.d.ts +11 -0
- package/dist/cli/install-native/run-native-install.d.ts +23 -0
- package/dist/cli/install-native-dev/index.d.ts +4 -0
- package/dist/cli/native-dev-platform-flag.d.ts +5 -0
- package/dist/cli/native-edition-hint.d.ts +10 -0
- package/dist/cli/types.d.ts +3 -2
- package/dist/cli-node/index.js +392 -112
- package/dist/config/schema/hooks.d.ts +1 -0
- package/dist/config-migration/harness-native-rename.d.ts +3 -0
- package/dist/create-hooks.d.ts +1 -0
- package/dist/features/native-edition-nudge/index.d.ts +2 -0
- package/dist/features/native-edition-nudge/tui.d.ts +33 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/native-edition-nudge/decide.d.ts +4 -0
- package/dist/hooks/native-edition-nudge/hook.d.ts +26 -0
- package/dist/hooks/native-edition-nudge/index.d.ts +5 -0
- package/dist/hooks/native-edition-nudge/state.d.ts +9 -0
- package/dist/hooks/native-edition-nudge/types.d.ts +38 -0
- package/dist/index.js +723 -351
- package/dist/plugin/hooks/create-core-hooks.d.ts +1 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts +2 -1
- package/dist/skills/browser/ATTRIBUTION.md +25 -0
- package/dist/skills/browser/SKILL.md +89 -0
- package/dist/skills/browser/references/commands.md +90 -0
- package/dist/skills/browser/references/install.md +71 -0
- package/dist/skills/browser/references/owned-engine/README.md +42 -0
- package/dist/skills/browser/references/owned-engine/frames-and-humans.md +39 -0
- package/dist/skills/browser/references/owned-engine/ladder.md +59 -0
- package/dist/skills/browser/references/owned-engine/network.md +42 -0
- package/dist/skills/browser/references/recipes/1password.md +59 -0
- package/dist/skills/browser/references/remote.md +24 -0
- package/dist/skills/browser/scripts/browser-doctor.mjs +41 -0
- package/dist/skills/browser/scripts/browser-env.mjs +41 -0
- package/dist/skills/browser/scripts/browser-install.mjs +51 -0
- package/dist/tui.js +517 -66
- package/package.json +14 -14
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +84 -11
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
- package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +24 -10
- package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-guard.js +8 -6
- package/packages/omo-codex/plugin/components/ulw-loop/dist/surface.d.ts +2 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/surface.js +21 -4
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-guard.ts +10 -5
- package/packages/omo-codex/plugin/components/ulw-loop/src/surface.ts +24 -6
- package/packages/omo-codex/plugin/components/ulw-loop/test/spawn-guard-native-reviewer.test.ts +207 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/spawn-guard.test.ts +6 -4
- package/packages/omo-codex/plugin/components/ulw-loop/test/surface.test.ts +43 -4
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/package-lock.json +12 -12
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/skills/browser/ATTRIBUTION.md +25 -0
- package/packages/omo-codex/plugin/skills/browser/SKILL.md +89 -0
- package/packages/omo-codex/plugin/skills/browser/agents/openai.yaml +2 -0
- package/packages/omo-codex/plugin/skills/browser/references/commands.md +90 -0
- package/packages/omo-codex/plugin/skills/browser/references/install.md +71 -0
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/README.md +42 -0
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/frames-and-humans.md +39 -0
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/ladder.md +59 -0
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/network.md +42 -0
- package/packages/omo-codex/plugin/skills/browser/references/recipes/1password.md +59 -0
- package/packages/omo-codex/plugin/skills/browser/references/remote.md +24 -0
- package/packages/omo-codex/plugin/skills/browser/scripts/browser-doctor.mjs +41 -0
- package/packages/omo-codex/plugin/skills/browser/scripts/browser-env.mjs +41 -0
- package/packages/omo-codex/plugin/skills/browser/scripts/browser-install.mjs +51 -0
- package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +1 -0
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +90 -17
- package/packages/shared-skills/skills/browser/ATTRIBUTION.md +25 -0
- package/packages/shared-skills/skills/browser/SKILL.md +89 -0
- package/packages/shared-skills/skills/browser/references/commands.md +90 -0
- package/packages/shared-skills/skills/browser/references/install.md +71 -0
- package/packages/shared-skills/skills/browser/references/owned-engine/README.md +42 -0
- package/packages/shared-skills/skills/browser/references/owned-engine/frames-and-humans.md +39 -0
- package/packages/shared-skills/skills/browser/references/owned-engine/ladder.md +59 -0
- package/packages/shared-skills/skills/browser/references/owned-engine/network.md +42 -0
- package/packages/shared-skills/skills/browser/references/recipes/1password.md +59 -0
- package/packages/shared-skills/skills/browser/references/remote.md +24 -0
- package/packages/shared-skills/skills/browser/scripts/browser-doctor.mjs +41 -0
- package/packages/shared-skills/skills/browser/scripts/browser-env.mjs +41 -0
- package/packages/shared-skills/skills/browser/scripts/browser-install.mjs +51 -0
- package/postinstall.mjs +3 -3
- package/dist/cli/install-senpi/index.d.ts +0 -1
- package/dist/cli/senpi-edition-hint.d.ts +0 -10
- package/dist/cli/senpi-platform-flag.d.ts +0 -4
package/dist/index.js
CHANGED
|
@@ -20050,6 +20050,7 @@ var AGENT_MODEL_REQUIREMENTS = {
|
|
|
20050
20050
|
},
|
|
20051
20051
|
librarian: {
|
|
20052
20052
|
fallbackChain: [
|
|
20053
|
+
{ providers: ["kimi-for-coding"], model: "kimi-for-coding-highspeed", variant: "off" },
|
|
20053
20054
|
{ providers: ["openai", "openai-codex"], model: "gpt-5.6-luna-fast", variant: "low" },
|
|
20054
20055
|
{ providers: ["deepseek"], model: "deepseek-v4-flash", variant: "max" },
|
|
20055
20056
|
{ providers: ["opencode-go", "bailian-coding-plan"], model: "qwen3.7-plus" },
|
|
@@ -20062,6 +20063,7 @@ var AGENT_MODEL_REQUIREMENTS = {
|
|
|
20062
20063
|
},
|
|
20063
20064
|
explore: {
|
|
20064
20065
|
fallbackChain: [
|
|
20066
|
+
{ providers: ["kimi-for-coding"], model: "kimi-for-coding-highspeed", variant: "off" },
|
|
20065
20067
|
{ providers: ["openai", "openai-codex"], model: "gpt-5.6-luna-fast", variant: "low" },
|
|
20066
20068
|
{ providers: ["deepseek"], model: "deepseek-v4-flash", variant: "max" },
|
|
20067
20069
|
{ providers: ["opencode-go", "bailian-coding-plan"], model: "qwen3.7-plus" },
|
|
@@ -20231,7 +20233,6 @@ var CATEGORY_MODEL_REQUIREMENTS = {
|
|
|
20231
20233
|
},
|
|
20232
20234
|
quick: {
|
|
20233
20235
|
fallbackChain: [
|
|
20234
|
-
{ providers: ["kimi-for-coding"], model: "kimi-for-coding-highspeed" },
|
|
20235
20236
|
{ providers: ["openai-codex"], model: "gpt-5.6-luna-fast", variant: "low" },
|
|
20236
20237
|
{ providers: ["deepseek"], model: "deepseek-v4-flash", variant: "off" },
|
|
20237
20238
|
{
|
|
@@ -20251,7 +20252,8 @@ var CATEGORY_MODEL_REQUIREMENTS = {
|
|
|
20251
20252
|
},
|
|
20252
20253
|
"unspecified-low": {
|
|
20253
20254
|
fallbackChain: [
|
|
20254
|
-
{ providers: ["
|
|
20255
|
+
{ providers: ["xiaomi", "opencode-go"], model: "mimo-v2.6-pro", variant: "max" },
|
|
20256
|
+
{ providers: ["xai", "github-copilot", "opencode-go"], model: "grok-4.7", variant: "xhigh" },
|
|
20255
20257
|
{
|
|
20256
20258
|
providers: ["openai", "openai-codex", "github-copilot", "opencode"],
|
|
20257
20259
|
model: "gpt-5.6-terra",
|
|
@@ -20273,11 +20275,6 @@ var CATEGORY_MODEL_REQUIREMENTS = {
|
|
|
20273
20275
|
},
|
|
20274
20276
|
"unspecified-high": {
|
|
20275
20277
|
fallbackChain: [
|
|
20276
|
-
{
|
|
20277
|
-
providers: ["openai", "openai-codex", "github-copilot", "opencode"],
|
|
20278
|
-
model: "gpt-6-astra",
|
|
20279
|
-
variant: "high"
|
|
20280
|
-
},
|
|
20281
20278
|
{
|
|
20282
20279
|
providers: ["anthropic", "anthropic-api", "github-copilot", "opencode"],
|
|
20283
20280
|
model: "claude-opus-5",
|
|
@@ -22034,6 +22031,36 @@ var SUPPLEMENTAL_MODEL_CAPABILITIES = {
|
|
|
22034
22031
|
output: 32768
|
|
22035
22032
|
}
|
|
22036
22033
|
},
|
|
22034
|
+
"grok-4.7": {
|
|
22035
|
+
id: "grok-4.7",
|
|
22036
|
+
family: "grok",
|
|
22037
|
+
reasoning: false,
|
|
22038
|
+
temperature: true,
|
|
22039
|
+
toolCall: true,
|
|
22040
|
+
modalities: {
|
|
22041
|
+
input: ["text", "image"],
|
|
22042
|
+
output: ["text"]
|
|
22043
|
+
},
|
|
22044
|
+
limit: {
|
|
22045
|
+
context: 500000,
|
|
22046
|
+
output: 32768
|
|
22047
|
+
}
|
|
22048
|
+
},
|
|
22049
|
+
"xai/grok-4.7": {
|
|
22050
|
+
id: "xai/grok-4.7",
|
|
22051
|
+
family: "grok",
|
|
22052
|
+
reasoning: false,
|
|
22053
|
+
temperature: true,
|
|
22054
|
+
toolCall: true,
|
|
22055
|
+
modalities: {
|
|
22056
|
+
input: ["text", "image"],
|
|
22057
|
+
output: ["text"]
|
|
22058
|
+
},
|
|
22059
|
+
limit: {
|
|
22060
|
+
context: 500000,
|
|
22061
|
+
output: 32768
|
|
22062
|
+
}
|
|
22063
|
+
},
|
|
22037
22064
|
"xai/grok-build-0.1": {
|
|
22038
22065
|
id: "xai/grok-build-0.1",
|
|
22039
22066
|
family: "grok",
|
|
@@ -22063,6 +22090,36 @@ var SUPPLEMENTAL_MODEL_CAPABILITIES = {
|
|
|
22063
22090
|
context: 256000,
|
|
22064
22091
|
output: 32768
|
|
22065
22092
|
}
|
|
22093
|
+
},
|
|
22094
|
+
"mimo-v2.6-pro": {
|
|
22095
|
+
id: "mimo-v2.6-pro",
|
|
22096
|
+
family: "mimo",
|
|
22097
|
+
reasoning: true,
|
|
22098
|
+
temperature: true,
|
|
22099
|
+
toolCall: true,
|
|
22100
|
+
modalities: {
|
|
22101
|
+
input: ["text", "image"],
|
|
22102
|
+
output: ["text"]
|
|
22103
|
+
},
|
|
22104
|
+
limit: {
|
|
22105
|
+
context: 1048576,
|
|
22106
|
+
output: 131072
|
|
22107
|
+
}
|
|
22108
|
+
},
|
|
22109
|
+
"xiaomi/mimo-v2.6-pro": {
|
|
22110
|
+
id: "xiaomi/mimo-v2.6-pro",
|
|
22111
|
+
family: "mimo",
|
|
22112
|
+
reasoning: true,
|
|
22113
|
+
temperature: true,
|
|
22114
|
+
toolCall: true,
|
|
22115
|
+
modalities: {
|
|
22116
|
+
input: ["text", "image"],
|
|
22117
|
+
output: ["text"]
|
|
22118
|
+
},
|
|
22119
|
+
limit: {
|
|
22120
|
+
context: 1048576,
|
|
22121
|
+
output: 131072
|
|
22122
|
+
}
|
|
22066
22123
|
}
|
|
22067
22124
|
};
|
|
22068
22125
|
|
|
@@ -23189,8 +23246,10 @@ var OmoGitMasterSettingsSchema = OmoGitMasterSettingsLayerSchema.extend({
|
|
|
23189
23246
|
// packages/omo-config-core/src/schema/harness.ts
|
|
23190
23247
|
import * as z6 from "zod";
|
|
23191
23248
|
var HARNESS_IDS = ["codex", "opencode", "omo"];
|
|
23192
|
-
var OMO_CONFIG_HARNESS_IDS = ["opencode", "
|
|
23249
|
+
var OMO_CONFIG_HARNESS_IDS = ["opencode", "native", "codex"];
|
|
23193
23250
|
var OmoHarnessIdSchema = z6.enum(OMO_CONFIG_HARNESS_IDS);
|
|
23251
|
+
var OMO_CONFIG_LEGACY_HARNESS_ALIASES = { senpi: "native" };
|
|
23252
|
+
var OMO_CONFIG_LEGACY_HARNESS_IDS = Object.keys(OMO_CONFIG_LEGACY_HARNESS_ALIASES);
|
|
23194
23253
|
|
|
23195
23254
|
// packages/omo-config-core/src/schema/memory.ts
|
|
23196
23255
|
import * as z7 from "zod";
|
|
@@ -23656,6 +23715,7 @@ var OmoConfigProfileSchema = z14.object({
|
|
|
23656
23715
|
telemetry: OmoTelemetrySettingsLayerSchema.optional(),
|
|
23657
23716
|
disabled_skills: OmoDisabledSkillsSchema.optional(),
|
|
23658
23717
|
"[opencode]": OmoOpenCodeHarnessConfigSchema.optional(),
|
|
23718
|
+
"[native]": OmoTypedHarnessConfigSchema.optional(),
|
|
23659
23719
|
"[senpi]": OmoTypedHarnessConfigSchema.optional(),
|
|
23660
23720
|
"[codex]": OmoTypedHarnessConfigSchema.optional()
|
|
23661
23721
|
}).strict();
|
|
@@ -23674,6 +23734,7 @@ var OmoConfigSchema = z14.object({
|
|
|
23674
23734
|
telemetry: OmoTelemetrySettingsSchema.optional(),
|
|
23675
23735
|
disabled_skills: OmoDisabledSkillsSchema.optional(),
|
|
23676
23736
|
"[opencode]": OmoOpenCodeHarnessConfigSchema.optional(),
|
|
23737
|
+
"[native]": OmoTypedHarnessConfigSchema.optional(),
|
|
23677
23738
|
"[senpi]": OmoTypedHarnessConfigSchema.optional(),
|
|
23678
23739
|
"[codex]": OmoTypedHarnessConfigSchema.optional(),
|
|
23679
23740
|
profiles: z14.record(z14.string(), OmoConfigProfileSchema).default({}),
|
|
@@ -23695,6 +23756,7 @@ var OmoConfigLayerSchema = z14.object({
|
|
|
23695
23756
|
telemetry: OmoTelemetrySettingsLayerSchema.optional(),
|
|
23696
23757
|
disabled_skills: OmoDisabledSkillsSchema.optional(),
|
|
23697
23758
|
"[opencode]": OmoOpenCodeHarnessConfigSchema.optional(),
|
|
23759
|
+
"[native]": OmoTypedHarnessConfigSchema.optional(),
|
|
23698
23760
|
"[senpi]": OmoTypedHarnessConfigSchema.optional(),
|
|
23699
23761
|
"[codex]": OmoTypedHarnessConfigSchema.optional(),
|
|
23700
23762
|
profiles: z14.record(z14.string(), OmoConfigProfileSchema).optional(),
|
|
@@ -23761,6 +23823,57 @@ function hasLegacyCategoryNames(document) {
|
|
|
23761
23823
|
return canonicalizeLegacyCategoryNames(document).renames.length > 0;
|
|
23762
23824
|
}
|
|
23763
23825
|
|
|
23826
|
+
// packages/omo-config-core/src/schema/legacy-harness-names.ts
|
|
23827
|
+
function canonicalHarnessName(name) {
|
|
23828
|
+
return Object.hasOwn(OMO_CONFIG_LEGACY_HARNESS_ALIASES, name) ? OMO_CONFIG_LEGACY_HARNESS_ALIASES[name] : name;
|
|
23829
|
+
}
|
|
23830
|
+
function harnessBlockKey(harness) {
|
|
23831
|
+
return `[${harness}]`;
|
|
23832
|
+
}
|
|
23833
|
+
function legacyHarnessOfBlockKey(key) {
|
|
23834
|
+
if (!key.startsWith("[") || !key.endsWith("]"))
|
|
23835
|
+
return;
|
|
23836
|
+
const harness = key.slice(1, -1);
|
|
23837
|
+
return Object.hasOwn(OMO_CONFIG_LEGACY_HARNESS_ALIASES, harness) ? harness : undefined;
|
|
23838
|
+
}
|
|
23839
|
+
function isRecord11(value) {
|
|
23840
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23841
|
+
}
|
|
23842
|
+
function canonicalizeBlocksIn(container, path, renames) {
|
|
23843
|
+
const result = {};
|
|
23844
|
+
for (const [key, value] of Object.entries(container)) {
|
|
23845
|
+
const legacyHarness = legacyHarnessOfBlockKey(key);
|
|
23846
|
+
if (legacyHarness === undefined) {
|
|
23847
|
+
result[key] = value;
|
|
23848
|
+
continue;
|
|
23849
|
+
}
|
|
23850
|
+
const canonical = harnessBlockKey(canonicalHarnessName(legacyHarness));
|
|
23851
|
+
const dropped = Object.hasOwn(container, canonical);
|
|
23852
|
+
renames.push({ canonical, dropped, legacy: key, path: [...path, key].join(".") });
|
|
23853
|
+
if (!dropped)
|
|
23854
|
+
result[canonical] = value;
|
|
23855
|
+
}
|
|
23856
|
+
return result;
|
|
23857
|
+
}
|
|
23858
|
+
function canonicalizeLegacyHarnessBlocks(document) {
|
|
23859
|
+
if (!isRecord11(document))
|
|
23860
|
+
return { document: {}, renames: [] };
|
|
23861
|
+
const renames = [];
|
|
23862
|
+
const canonicalized = canonicalizeBlocksIn(document, [], renames);
|
|
23863
|
+
const profiles = canonicalized["profiles"];
|
|
23864
|
+
if (isRecord11(profiles)) {
|
|
23865
|
+
const canonicalProfiles = {};
|
|
23866
|
+
for (const [name, profile] of Object.entries(profiles)) {
|
|
23867
|
+
canonicalProfiles[name] = isRecord11(profile) ? canonicalizeBlocksIn(profile, ["profiles", name], renames) : profile;
|
|
23868
|
+
}
|
|
23869
|
+
canonicalized["profiles"] = canonicalProfiles;
|
|
23870
|
+
}
|
|
23871
|
+
return { document: canonicalized, renames };
|
|
23872
|
+
}
|
|
23873
|
+
function hasLegacyHarnessBlocks(document) {
|
|
23874
|
+
return canonicalizeLegacyHarnessBlocks(document).renames.length > 0;
|
|
23875
|
+
}
|
|
23876
|
+
|
|
23764
23877
|
// packages/omo-config-core/src/loader/loader.ts
|
|
23765
23878
|
init_main();
|
|
23766
23879
|
|
|
@@ -23901,7 +24014,7 @@ function resolveOmoConfigPaths(options) {
|
|
|
23901
24014
|
}
|
|
23902
24015
|
|
|
23903
24016
|
// packages/omo-config-core/src/loader/resolution.ts
|
|
23904
|
-
var HARNESS_KEYS = [...new Set([...HARNESS_IDS, ...OMO_CONFIG_HARNESS_IDS])].map((harness) =>
|
|
24017
|
+
var HARNESS_KEYS = [...new Set([...HARNESS_IDS, ...OMO_CONFIG_HARNESS_IDS, ...OMO_CONFIG_LEGACY_HARNESS_IDS])].map((harness) => harnessBlockKey(harness));
|
|
23905
24018
|
function profileName(value) {
|
|
23906
24019
|
return value === "" ? undefined : value;
|
|
23907
24020
|
}
|
|
@@ -23930,7 +24043,13 @@ function withoutControlKeys(config) {
|
|
|
23930
24043
|
function harnessLayer(config, harness) {
|
|
23931
24044
|
if (harness === undefined)
|
|
23932
24045
|
return {};
|
|
23933
|
-
|
|
24046
|
+
const canonical = canonicalHarnessName(harness);
|
|
24047
|
+
const legacyKeys = Object.entries(OMO_CONFIG_LEGACY_HARNESS_ALIASES).filter(([, target]) => target === canonical).map(([legacy]) => harnessBlockKey(legacy));
|
|
24048
|
+
let layer = {};
|
|
24049
|
+
for (const key of [...legacyKeys, harnessBlockKey(canonical)]) {
|
|
24050
|
+
layer = mergeOmoConfigRecords(layer, toRecord(config[key]) ?? {});
|
|
24051
|
+
}
|
|
24052
|
+
return layer;
|
|
23934
24053
|
}
|
|
23935
24054
|
function resolveOmoConfigView(options) {
|
|
23936
24055
|
const profiles = toRecord(options.config["profiles"]);
|
|
@@ -23981,6 +24100,7 @@ var DEFAULT_RAW_CONFIG = {
|
|
|
23981
24100
|
function stripResolutionControlKeys(config) {
|
|
23982
24101
|
const {
|
|
23983
24102
|
"[codex]": _codex,
|
|
24103
|
+
"[native]": _native,
|
|
23984
24104
|
"[opencode]": _opencode,
|
|
23985
24105
|
"[senpi]": _senpi,
|
|
23986
24106
|
profiles: _profiles,
|
|
@@ -24006,21 +24126,21 @@ function hasUnsafeUnrecognizedKey(issues) {
|
|
|
24006
24126
|
function hasTamperedPrototype(value) {
|
|
24007
24127
|
if (Array.isArray(value))
|
|
24008
24128
|
return value.some((entry) => hasTamperedPrototype(entry));
|
|
24009
|
-
if (!
|
|
24129
|
+
if (!isRecord12(value))
|
|
24010
24130
|
return false;
|
|
24011
24131
|
const prototype = Object.getPrototypeOf(value);
|
|
24012
24132
|
if (prototype !== Object.prototype && prototype !== null)
|
|
24013
24133
|
return true;
|
|
24014
24134
|
return Object.values(value).some((entry) => hasTamperedPrototype(entry));
|
|
24015
24135
|
}
|
|
24016
|
-
function
|
|
24136
|
+
function isRecord12(value) {
|
|
24017
24137
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24018
24138
|
}
|
|
24019
24139
|
function containerAt(record, path) {
|
|
24020
24140
|
let container = record;
|
|
24021
24141
|
for (const segment of path) {
|
|
24022
24142
|
const next = container[segment];
|
|
24023
|
-
if (!
|
|
24143
|
+
if (!isRecord12(next))
|
|
24024
24144
|
return null;
|
|
24025
24145
|
container = next;
|
|
24026
24146
|
}
|
|
@@ -24131,6 +24251,15 @@ function legacyCategoryDiagnostic(path, renames) {
|
|
|
24131
24251
|
issuePaths: renames.map((rename) => rename.path)
|
|
24132
24252
|
};
|
|
24133
24253
|
}
|
|
24254
|
+
function legacyHarnessDiagnostic(path, renames) {
|
|
24255
|
+
const detail = renames.map((rename) => rename.dropped ? `${rename.path} ignored because ${rename.canonical} is also configured` : `${rename.path} renamed to ${rename.canonical}`).join(", ");
|
|
24256
|
+
return {
|
|
24257
|
+
kind: "deprecated-keys",
|
|
24258
|
+
message: `Deprecated harness block in ${path}: ${detail}. Rename it; the alias is removed in a future release.`,
|
|
24259
|
+
path,
|
|
24260
|
+
issuePaths: renames.map((rename) => rename.path)
|
|
24261
|
+
};
|
|
24262
|
+
}
|
|
24134
24263
|
function loadOmoConfig(options = {}) {
|
|
24135
24264
|
const fileSystem = options.fileSystem ?? DEFAULT_READ_FILE_SYSTEM;
|
|
24136
24265
|
const cwd = options.cwd ?? process.cwd();
|
|
@@ -24153,8 +24282,12 @@ function loadOmoConfig(options = {}) {
|
|
|
24153
24282
|
if (canonicalized.renames.length > 0) {
|
|
24154
24283
|
diagnostics.push(legacyCategoryDiagnostic(candidate.path, canonicalized.renames));
|
|
24155
24284
|
}
|
|
24156
|
-
|
|
24157
|
-
|
|
24285
|
+
const harnessCanonicalized = canonicalizeLegacyHarnessBlocks(canonicalized.document);
|
|
24286
|
+
if (harnessCanonicalized.renames.length > 0) {
|
|
24287
|
+
diagnostics.push(legacyHarnessDiagnostic(candidate.path, harnessCanonicalized.renames));
|
|
24288
|
+
}
|
|
24289
|
+
layers.push({ config: harnessCanonicalized.document, source: loaded.source });
|
|
24290
|
+
merged = mergeOmoConfigRecords(merged, harnessCanonicalized.document);
|
|
24158
24291
|
}
|
|
24159
24292
|
}
|
|
24160
24293
|
const requestedProfile = resolveOmoProfileName({
|
|
@@ -25863,7 +25996,8 @@ var HookNameSchema = z32.enum([
|
|
|
25863
25996
|
"webfetch-redirect-guard",
|
|
25864
25997
|
"fsync-skip-warning",
|
|
25865
25998
|
"plan-format-validator",
|
|
25866
|
-
"legacy-plugin-toast"
|
|
25999
|
+
"legacy-plugin-toast",
|
|
26000
|
+
"native-edition-nudge"
|
|
25867
26001
|
]);
|
|
25868
26002
|
// packages/omo-opencode/src/config/schema/i18n.ts
|
|
25869
26003
|
import { z as z33 } from "zod";
|
|
@@ -27117,21 +27251,21 @@ var OPENAI_CATEGORIES = [
|
|
|
27117
27251
|
},
|
|
27118
27252
|
{
|
|
27119
27253
|
name: "quick",
|
|
27120
|
-
config: { model: "
|
|
27254
|
+
config: { model: "openai/gpt-5.6-luna-fast", variant: "low" },
|
|
27121
27255
|
description: "Trivial tasks - single file changes, typo fixes, simple modifications",
|
|
27122
27256
|
callerGuidance: QUICK_CATEGORY_CALLER_GUIDANCE,
|
|
27123
27257
|
promptAppend: QUICK_CATEGORY_PROMPT_APPEND
|
|
27124
27258
|
},
|
|
27125
27259
|
{
|
|
27126
27260
|
name: "unspecified-low",
|
|
27127
|
-
config: { model: "
|
|
27261
|
+
config: { model: "xiaomi/mimo-v2.6-pro", variant: "max" },
|
|
27128
27262
|
description: "Tasks that don't fit other categories, low effort required",
|
|
27129
27263
|
callerGuidance: UNSPECIFIED_LOW_CATEGORY_CALLER_GUIDANCE,
|
|
27130
27264
|
promptAppend: UNSPECIFIED_LOW_CATEGORY_PROMPT_APPEND
|
|
27131
27265
|
},
|
|
27132
27266
|
{
|
|
27133
27267
|
name: "unspecified-high",
|
|
27134
|
-
config: { model: "
|
|
27268
|
+
config: { model: "anthropic/claude-opus-5", variant: "xhigh" },
|
|
27135
27269
|
description: "Tasks that don't fit other categories, high effort required",
|
|
27136
27270
|
callerGuidance: UNSPECIFIED_HIGH_CATEGORY_CALLER_GUIDANCE,
|
|
27137
27271
|
promptAppend: UNSPECIFIED_HIGH_CATEGORY_PROMPT_APPEND,
|
|
@@ -97276,7 +97410,7 @@ function getCachedVersion(options = {}) {
|
|
|
97276
97410
|
// package.json
|
|
97277
97411
|
var package_default = {
|
|
97278
97412
|
name: "oh-my-opencode",
|
|
97279
|
-
version: "5.0.0-beta.
|
|
97413
|
+
version: "5.0.0-beta.83",
|
|
97280
97414
|
description: "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
|
|
97281
97415
|
main: "./dist/index.js",
|
|
97282
97416
|
types: "dist/index.d.ts",
|
|
@@ -97459,7 +97593,7 @@ var package_default = {
|
|
|
97459
97593
|
zod: "^4.6.5"
|
|
97460
97594
|
},
|
|
97461
97595
|
devDependencies: {
|
|
97462
|
-
"@code-yeongyu/senpi": "2026.9.22",
|
|
97596
|
+
"@code-yeongyu/senpi": "2026.9.22-2",
|
|
97463
97597
|
"@oh-my-opencode/agents-md-core": "workspace:*",
|
|
97464
97598
|
"@oh-my-opencode/ast-grep-mcp": "workspace:*",
|
|
97465
97599
|
"@oh-my-opencode/boulder-state": "workspace:*",
|
|
@@ -97499,18 +97633,18 @@ var package_default = {
|
|
|
97499
97633
|
typescript: "^7.0.2"
|
|
97500
97634
|
},
|
|
97501
97635
|
optionalDependencies: {
|
|
97502
|
-
"oh-my-opencode-darwin-arm64": "5.0.0-beta.
|
|
97503
|
-
"oh-my-opencode-darwin-x64": "5.0.0-beta.
|
|
97504
|
-
"oh-my-opencode-darwin-x64-baseline": "5.0.0-beta.
|
|
97505
|
-
"oh-my-opencode-linux-arm64": "5.0.0-beta.
|
|
97506
|
-
"oh-my-opencode-linux-arm64-musl": "5.0.0-beta.
|
|
97507
|
-
"oh-my-opencode-linux-x64": "5.0.0-beta.
|
|
97508
|
-
"oh-my-opencode-linux-x64-baseline": "5.0.0-beta.
|
|
97509
|
-
"oh-my-opencode-linux-x64-musl": "5.0.0-beta.
|
|
97510
|
-
"oh-my-opencode-linux-x64-musl-baseline": "5.0.0-beta.
|
|
97511
|
-
"oh-my-opencode-windows-arm64": "5.0.0-beta.
|
|
97512
|
-
"oh-my-opencode-windows-x64": "5.0.0-beta.
|
|
97513
|
-
"oh-my-opencode-windows-x64-baseline": "5.0.0-beta.
|
|
97636
|
+
"oh-my-opencode-darwin-arm64": "5.0.0-beta.83",
|
|
97637
|
+
"oh-my-opencode-darwin-x64": "5.0.0-beta.83",
|
|
97638
|
+
"oh-my-opencode-darwin-x64-baseline": "5.0.0-beta.83",
|
|
97639
|
+
"oh-my-opencode-linux-arm64": "5.0.0-beta.83",
|
|
97640
|
+
"oh-my-opencode-linux-arm64-musl": "5.0.0-beta.83",
|
|
97641
|
+
"oh-my-opencode-linux-x64": "5.0.0-beta.83",
|
|
97642
|
+
"oh-my-opencode-linux-x64-baseline": "5.0.0-beta.83",
|
|
97643
|
+
"oh-my-opencode-linux-x64-musl": "5.0.0-beta.83",
|
|
97644
|
+
"oh-my-opencode-linux-x64-musl-baseline": "5.0.0-beta.83",
|
|
97645
|
+
"oh-my-opencode-windows-arm64": "5.0.0-beta.83",
|
|
97646
|
+
"oh-my-opencode-windows-x64": "5.0.0-beta.83",
|
|
97647
|
+
"oh-my-opencode-windows-x64-baseline": "5.0.0-beta.83"
|
|
97514
97648
|
},
|
|
97515
97649
|
overrides: {
|
|
97516
97650
|
"@earendil-works/pi-agent-core": "0.84.2",
|
|
@@ -98034,14 +98168,14 @@ function transformConfigJsoncSources(input) {
|
|
|
98034
98168
|
const omo = recordAt(legacy, "[omo]");
|
|
98035
98169
|
const senpi = recordAt(legacy, "[senpi]");
|
|
98036
98170
|
const history = legacyMigrationHistory(input.discovered, input.sources);
|
|
98037
|
-
const diagnostics = omo !== undefined && senpi !== undefined ? ["conflict: [
|
|
98171
|
+
const diagnostics = omo !== undefined && senpi !== undefined ? ["conflict: [native] legacy [omo] kept [native]"] : [];
|
|
98038
98172
|
return {
|
|
98039
98173
|
diagnostics,
|
|
98040
98174
|
document: {
|
|
98041
98175
|
$schema: OMO_SCHEMA_URL,
|
|
98042
98176
|
...recordAt(legacy, "[opencode]") === undefined ? {} : { "[opencode]": recordAt(legacy, "[opencode]") },
|
|
98043
98177
|
...recordAt(legacy, "[codex]") === undefined ? {} : { "[codex]": recordAt(legacy, "[codex]") },
|
|
98044
|
-
...senpi === undefined && omo === undefined ? {} : { "[
|
|
98178
|
+
...senpi === undefined && omo === undefined ? {} : { "[native]": senpi ?? omo },
|
|
98045
98179
|
...Object.keys(history).length === 0 ? {} : { legacy_migrations: history }
|
|
98046
98180
|
}
|
|
98047
98181
|
};
|
|
@@ -98293,7 +98427,7 @@ function normalizeTypedBlock(value, path, diagnostics, recurseProfiles) {
|
|
|
98293
98427
|
}
|
|
98294
98428
|
if (result["models"] !== undefined)
|
|
98295
98429
|
result["models"] = normalizeCatalog(result["models"]);
|
|
98296
|
-
for (const harness of ["[senpi]", "[codex]"]) {
|
|
98430
|
+
for (const harness of ["[senpi]", "[native]", "[codex]"]) {
|
|
98297
98431
|
if (result[harness] !== undefined)
|
|
98298
98432
|
result[harness] = normalizeTypedBlock(result[harness], [...path, harness], diagnostics, false);
|
|
98299
98433
|
}
|
|
@@ -98339,6 +98473,16 @@ function transformCategoryDeepSplit(document) {
|
|
|
98339
98473
|
};
|
|
98340
98474
|
}
|
|
98341
98475
|
|
|
98476
|
+
// packages/omo-opencode/src/config-migration/harness-native-rename.ts
|
|
98477
|
+
var HARNESS_NATIVE_RENAME_MIGRATION_ID = "2026-09-harness-native-rename";
|
|
98478
|
+
function transformHarnessNativeRename(document) {
|
|
98479
|
+
const { document: canonicalized, renames } = canonicalizeLegacyHarnessBlocks(document);
|
|
98480
|
+
return {
|
|
98481
|
+
diagnostics: renames.map((rename) => rename.dropped ? `${rename.path} removed: ${rename.canonical} is already configured` : `${rename.path} renamed to ${rename.canonical}`),
|
|
98482
|
+
document: canonicalized
|
|
98483
|
+
};
|
|
98484
|
+
}
|
|
98485
|
+
|
|
98342
98486
|
// packages/omo-opencode/src/config-migration/migration-plans.ts
|
|
98343
98487
|
function backupTimestamp(value) {
|
|
98344
98488
|
return value ?? new Date().toISOString().replace(/[:.]/g, "-");
|
|
@@ -98417,6 +98561,18 @@ function categoryDeepSplitPlan(targetPath) {
|
|
|
98417
98561
|
transform: inspect
|
|
98418
98562
|
};
|
|
98419
98563
|
}
|
|
98564
|
+
function harnessNativeRenamePlan(targetPath) {
|
|
98565
|
+
const inspect = (sources) => transformHarnessNativeRename(sources[0]?.value);
|
|
98566
|
+
return {
|
|
98567
|
+
id: HARNESS_NATIVE_RENAME_MIGRATION_ID,
|
|
98568
|
+
inspect,
|
|
98569
|
+
mode: "replace-target",
|
|
98570
|
+
shouldRun: hasLegacyHarnessBlocks,
|
|
98571
|
+
sources: [],
|
|
98572
|
+
targetPath,
|
|
98573
|
+
transform: inspect
|
|
98574
|
+
};
|
|
98575
|
+
}
|
|
98420
98576
|
function existingOmoConfigPath(directory, options) {
|
|
98421
98577
|
const fileSystem = discoveryFileSystem(options);
|
|
98422
98578
|
for (const fileName of ["omo.jsonc", "omo.json"]) {
|
|
@@ -98480,7 +98636,8 @@ function createLegacyConfigMigrationPlans(options) {
|
|
|
98480
98636
|
return [
|
|
98481
98637
|
...legacyPlans,
|
|
98482
98638
|
...inPlaceTargets.map(reasoningPlan),
|
|
98483
|
-
...inPlaceTargets.map(categoryDeepSplitPlan)
|
|
98639
|
+
...inPlaceTargets.map(categoryDeepSplitPlan),
|
|
98640
|
+
...inPlaceTargets.map(harnessNativeRenamePlan)
|
|
98484
98641
|
];
|
|
98485
98642
|
}
|
|
98486
98643
|
// packages/omo-opencode/src/startup-migration.ts
|
|
@@ -122789,6 +122946,218 @@ Run: bunx ${PUBLISHED_PACKAGE_NAME} install`,
|
|
|
122789
122946
|
}
|
|
122790
122947
|
};
|
|
122791
122948
|
}
|
|
122949
|
+
// packages/omo-opencode/src/hooks/native-edition-nudge/types.ts
|
|
122950
|
+
var NUDGE_STATE_VERSION = 1;
|
|
122951
|
+
var NUDGE_INTERVALS_MS = [3, 7, 14].map((days) => days * 24 * 60 * 60 * 1000);
|
|
122952
|
+
var NUDGE_AUTO_SHOW_CAP = 4;
|
|
122953
|
+
var NUDGE_SNOOZE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
122954
|
+
var NUDGE_CORRUPT_RECOVERY_MS = 3 * 24 * 60 * 60 * 1000;
|
|
122955
|
+
|
|
122956
|
+
// packages/omo-opencode/src/hooks/native-edition-nudge/decide.ts
|
|
122957
|
+
function freshState(now, version) {
|
|
122958
|
+
return {
|
|
122959
|
+
schemaVersion: NUDGE_STATE_VERSION,
|
|
122960
|
+
autoShows: 0,
|
|
122961
|
+
lastShownAt: null,
|
|
122962
|
+
nextEligibleAt: now,
|
|
122963
|
+
decision: "none",
|
|
122964
|
+
decidedAt: null,
|
|
122965
|
+
writtenBy: version
|
|
122966
|
+
};
|
|
122967
|
+
}
|
|
122968
|
+
function recoveredState(now, version) {
|
|
122969
|
+
return { ...freshState(now, version), nextEligibleAt: now + NUDGE_CORRUPT_RECOVERY_MS };
|
|
122970
|
+
}
|
|
122971
|
+
function shownState(previous, now, version) {
|
|
122972
|
+
const autoShows = previous.autoShows + 1;
|
|
122973
|
+
const interval = NUDGE_INTERVALS_MS[Math.min(autoShows - 1, NUDGE_INTERVALS_MS.length - 1)] ?? 0;
|
|
122974
|
+
return {
|
|
122975
|
+
...previous,
|
|
122976
|
+
schemaVersion: NUDGE_STATE_VERSION,
|
|
122977
|
+
autoShows,
|
|
122978
|
+
lastShownAt: now,
|
|
122979
|
+
nextEligibleAt: now + interval,
|
|
122980
|
+
writtenBy: version
|
|
122981
|
+
};
|
|
122982
|
+
}
|
|
122983
|
+
function decideNativeEditionNudge(input) {
|
|
122984
|
+
const deny = (reason, nextState = null) => ({ show: false, reason, nextState });
|
|
122985
|
+
if (input.state !== "missing" && input.state !== "corrupt") {
|
|
122986
|
+
if (input.state.decision === "never")
|
|
122987
|
+
return deny("opted-out");
|
|
122988
|
+
if (input.state.decision === "migrated")
|
|
122989
|
+
return deny("already-migrated");
|
|
122990
|
+
}
|
|
122991
|
+
if (input.nativeEditionInstalled)
|
|
122992
|
+
return deny("already-migrated");
|
|
122993
|
+
if (input.hookDisabled)
|
|
122994
|
+
return deny("opted-out");
|
|
122995
|
+
if (!input.interactive)
|
|
122996
|
+
return deny("non-interactive");
|
|
122997
|
+
if (input.childSession)
|
|
122998
|
+
return deny("child-session");
|
|
122999
|
+
if (input.shownThisProcess)
|
|
123000
|
+
return deny("already-shown-this-process");
|
|
123001
|
+
if (!input.toastAvailable)
|
|
123002
|
+
return deny("toast-unavailable");
|
|
123003
|
+
if (!input.stateWritable)
|
|
123004
|
+
return deny("state-unwritable");
|
|
123005
|
+
if (input.state === "corrupt")
|
|
123006
|
+
return deny("state-corrupt-recovering", recoveredState(input.now, input.version));
|
|
123007
|
+
const current = input.state === "missing" ? freshState(input.now, input.version) : input.state;
|
|
123008
|
+
if (current.autoShows >= NUDGE_AUTO_SHOW_CAP)
|
|
123009
|
+
return deny("lifetime-cap-reached");
|
|
123010
|
+
if (input.now < current.nextEligibleAt)
|
|
123011
|
+
return deny("not-yet-eligible");
|
|
123012
|
+
return { show: true, reason: "eligible", nextState: shownState(current, input.now, input.version) };
|
|
123013
|
+
}
|
|
123014
|
+
// packages/omo-opencode/src/hooks/native-edition-nudge/hook.ts
|
|
123015
|
+
import { existsSync as existsSync84 } from "fs";
|
|
123016
|
+
import { homedir as homedir21 } from "os";
|
|
123017
|
+
import { join as join104 } from "path";
|
|
123018
|
+
|
|
123019
|
+
// packages/omo-opencode/src/cli/native-edition-hint.ts
|
|
123020
|
+
var NATIVE_EDITION_INSTALL_COMMAND = "bun add -g omo-ai@beta";
|
|
123021
|
+
|
|
123022
|
+
// packages/omo-opencode/src/hooks/native-edition-nudge/hook.ts
|
|
123023
|
+
init_logger2();
|
|
123024
|
+
|
|
123025
|
+
// packages/omo-opencode/src/hooks/native-edition-nudge/state.ts
|
|
123026
|
+
import { mkdirSync as mkdirSync20, readFileSync as readFileSync56, unlinkSync as unlinkSync15, writeFileSync as writeFileSync21 } from "fs";
|
|
123027
|
+
import { join as join103 } from "path";
|
|
123028
|
+
var NUDGE_STATE_FILE = "native-nudge.json";
|
|
123029
|
+
function isDecision(value) {
|
|
123030
|
+
return value === "none" || value === "snoozed" || value === "never" || value === "migrated";
|
|
123031
|
+
}
|
|
123032
|
+
function isEpoch(value) {
|
|
123033
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
123034
|
+
}
|
|
123035
|
+
function parseNudgeState(raw) {
|
|
123036
|
+
let parsed;
|
|
123037
|
+
try {
|
|
123038
|
+
parsed = JSON.parse(raw);
|
|
123039
|
+
} catch {
|
|
123040
|
+
return "corrupt";
|
|
123041
|
+
}
|
|
123042
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
123043
|
+
return "corrupt";
|
|
123044
|
+
const record = parsed;
|
|
123045
|
+
if (!isDecision(record["decision"]))
|
|
123046
|
+
return "corrupt";
|
|
123047
|
+
if (!isEpoch(record["nextEligibleAt"]))
|
|
123048
|
+
return "corrupt";
|
|
123049
|
+
const autoShows = record["autoShows"];
|
|
123050
|
+
return {
|
|
123051
|
+
schemaVersion: typeof record["schemaVersion"] === "number" ? record["schemaVersion"] : NUDGE_STATE_VERSION,
|
|
123052
|
+
autoShows: typeof autoShows === "number" && Number.isSafeInteger(autoShows) && autoShows >= 0 ? autoShows : 0,
|
|
123053
|
+
lastShownAt: isEpoch(record["lastShownAt"]) ? record["lastShownAt"] : null,
|
|
123054
|
+
nextEligibleAt: record["nextEligibleAt"],
|
|
123055
|
+
decision: record["decision"],
|
|
123056
|
+
decidedAt: isEpoch(record["decidedAt"]) ? record["decidedAt"] : null,
|
|
123057
|
+
writtenBy: typeof record["writtenBy"] === "string" ? record["writtenBy"] : "unknown"
|
|
123058
|
+
};
|
|
123059
|
+
}
|
|
123060
|
+
function createNudgeStateStore(stateDir) {
|
|
123061
|
+
const path = join103(stateDir, NUDGE_STATE_FILE);
|
|
123062
|
+
return {
|
|
123063
|
+
read: () => {
|
|
123064
|
+
let raw;
|
|
123065
|
+
try {
|
|
123066
|
+
raw = readFileSync56(path, "utf8");
|
|
123067
|
+
} catch {
|
|
123068
|
+
return "missing";
|
|
123069
|
+
}
|
|
123070
|
+
return parseNudgeState(raw);
|
|
123071
|
+
},
|
|
123072
|
+
write: (state) => {
|
|
123073
|
+
try {
|
|
123074
|
+
mkdirSync20(stateDir, { recursive: true });
|
|
123075
|
+
writeFileSync21(path, `${JSON.stringify(state, null, 2)}
|
|
123076
|
+
`, { mode: 384 });
|
|
123077
|
+
return true;
|
|
123078
|
+
} catch {
|
|
123079
|
+
return false;
|
|
123080
|
+
}
|
|
123081
|
+
},
|
|
123082
|
+
probeWritable: () => {
|
|
123083
|
+
const probe = join103(stateDir, `.${NUDGE_STATE_FILE}.probe`);
|
|
123084
|
+
try {
|
|
123085
|
+
mkdirSync20(stateDir, { recursive: true });
|
|
123086
|
+
writeFileSync21(probe, "", { mode: 384 });
|
|
123087
|
+
} catch {
|
|
123088
|
+
return false;
|
|
123089
|
+
}
|
|
123090
|
+
try {
|
|
123091
|
+
unlinkSync15(probe);
|
|
123092
|
+
} catch {}
|
|
123093
|
+
return true;
|
|
123094
|
+
}
|
|
123095
|
+
};
|
|
123096
|
+
}
|
|
123097
|
+
|
|
123098
|
+
// packages/omo-opencode/src/hooks/native-edition-nudge/hook.ts
|
|
123099
|
+
var NATIVE_NUDGE_TOAST_TITLE = "Try OmO Native: no host app needed";
|
|
123100
|
+
var NATIVE_NUDGE_TOAST_MESSAGE = `Same agent, one binary, nothing else to keep updated.
|
|
123101
|
+
Install: ${NATIVE_EDITION_INSTALL_COMMAND}`;
|
|
123102
|
+
function nativeEditionStateDir() {
|
|
123103
|
+
return join104(getUserConfigDir(), "oh-my-openagent");
|
|
123104
|
+
}
|
|
123105
|
+
function detectNativeEdition() {
|
|
123106
|
+
return existsSync84(join104(homedir21(), ".omo", "agent"));
|
|
123107
|
+
}
|
|
123108
|
+
function defaultInteractive() {
|
|
123109
|
+
if (process.env["CI"] !== undefined && process.env["CI"] !== "")
|
|
123110
|
+
return false;
|
|
123111
|
+
if (process.env["OMO_NON_INTERACTIVE"] === "1")
|
|
123112
|
+
return false;
|
|
123113
|
+
return process.stdout.isTTY === true;
|
|
123114
|
+
}
|
|
123115
|
+
function createNativeEditionNudgeHook(ctx, deps = {}) {
|
|
123116
|
+
let shownThisProcess = false;
|
|
123117
|
+
const store = deps.store ?? createNudgeStateStore(nativeEditionStateDir());
|
|
123118
|
+
const detect = deps.detectNativeEdition ?? detectNativeEdition;
|
|
123119
|
+
const now = deps.now ?? (() => Date.now());
|
|
123120
|
+
const interactive = deps.interactive ?? defaultInteractive;
|
|
123121
|
+
const version = deps.version ?? "unknown";
|
|
123122
|
+
const logFn = deps.log ?? log2;
|
|
123123
|
+
const persist = (next) => next === null ? true : store.write(next);
|
|
123124
|
+
return {
|
|
123125
|
+
event: async ({ event }) => {
|
|
123126
|
+
if (event.type !== "session.created")
|
|
123127
|
+
return;
|
|
123128
|
+
const props = event.properties;
|
|
123129
|
+
const decision = decideNativeEditionNudge({
|
|
123130
|
+
now: now(),
|
|
123131
|
+
state: store.read(),
|
|
123132
|
+
nativeEditionInstalled: detect(),
|
|
123133
|
+
hookDisabled: false,
|
|
123134
|
+
interactive: interactive(),
|
|
123135
|
+
childSession: props?.info?.parentID !== undefined,
|
|
123136
|
+
shownThisProcess,
|
|
123137
|
+
stateWritable: store.probeWritable(),
|
|
123138
|
+
toastAvailable: typeof ctx.client?.tui?.showToast === "function",
|
|
123139
|
+
version
|
|
123140
|
+
});
|
|
123141
|
+
if (!decision.show) {
|
|
123142
|
+
persist(decision.nextState);
|
|
123143
|
+
return;
|
|
123144
|
+
}
|
|
123145
|
+
if (!persist(decision.nextState)) {
|
|
123146
|
+
logFn("[native-edition-nudge] state write failed; suppressing the toast");
|
|
123147
|
+
return;
|
|
123148
|
+
}
|
|
123149
|
+
shownThisProcess = true;
|
|
123150
|
+
await ctx.client.tui.showToast({
|
|
123151
|
+
body: {
|
|
123152
|
+
title: NATIVE_NUDGE_TOAST_TITLE,
|
|
123153
|
+
message: NATIVE_NUDGE_TOAST_MESSAGE,
|
|
123154
|
+
variant: "info",
|
|
123155
|
+
duration: 1e4
|
|
123156
|
+
}
|
|
123157
|
+
}).catch(() => {});
|
|
123158
|
+
}
|
|
123159
|
+
};
|
|
123160
|
+
}
|
|
122792
123161
|
// packages/omo-opencode/src/shared/fsync-skip-warning-formatter.ts
|
|
122793
123162
|
var MAX_PATH_LINES = 5;
|
|
122794
123163
|
function selectMostCommonClassification(entries) {
|
|
@@ -122922,7 +123291,7 @@ function createNotepadWriteGuardHook() {
|
|
|
122922
123291
|
};
|
|
122923
123292
|
}
|
|
122924
123293
|
// packages/omo-opencode/src/hooks/plan-format-validator/hook.ts
|
|
122925
|
-
import { existsSync as
|
|
123294
|
+
import { existsSync as existsSync85, readFileSync as readFileSync57, writeFileSync as writeFileSync22 } from "fs";
|
|
122926
123295
|
import { resolve as resolve25 } from "path";
|
|
122927
123296
|
init_logger2();
|
|
122928
123297
|
var WRITE_TOOLS = new Set(["Write", "Edit", "write", "edit"]);
|
|
@@ -123120,13 +123489,13 @@ function createPlanFormatValidatorHook(_ctx) {
|
|
|
123120
123489
|
if (!isPlanFilePath(filePath))
|
|
123121
123490
|
return;
|
|
123122
123491
|
const resolvedPath = resolve25(_ctx.directory, filePath);
|
|
123123
|
-
if (!
|
|
123492
|
+
if (!existsSync85(resolvedPath))
|
|
123124
123493
|
return;
|
|
123125
|
-
let content =
|
|
123494
|
+
let content = readFileSync57(resolvedPath, "utf-8");
|
|
123126
123495
|
const effort = normalizePlanEffort(content);
|
|
123127
123496
|
if (effort !== null) {
|
|
123128
123497
|
content = effort.content;
|
|
123129
|
-
|
|
123498
|
+
writeFileSync22(resolvedPath, content, "utf-8");
|
|
123130
123499
|
log2(`[plan-format-validator] Plan ${filePath}: Effort "${effort.original}" normalized to ${effort.band}`, {
|
|
123131
123500
|
sessionID: input.sessionID,
|
|
123132
123501
|
filePath
|
|
@@ -123240,19 +123609,19 @@ tool.schema = z53;
|
|
|
123240
123609
|
|
|
123241
123610
|
// packages/omo-opencode/src/shared/ripgrep-cli.ts
|
|
123242
123611
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
123243
|
-
import { existsSync as
|
|
123244
|
-
import { dirname as dirname35, join as
|
|
123612
|
+
import { existsSync as existsSync87 } from "fs";
|
|
123613
|
+
import { dirname as dirname35, join as join106 } from "path";
|
|
123245
123614
|
|
|
123246
123615
|
// packages/omo-opencode/src/tools/grep/downloader.ts
|
|
123247
|
-
import { existsSync as
|
|
123248
|
-
import { join as
|
|
123616
|
+
import { existsSync as existsSync86, readdirSync as readdirSync24 } from "fs";
|
|
123617
|
+
import { join as join105 } from "path";
|
|
123249
123618
|
init_plugin_identity();
|
|
123250
123619
|
function findFileRecursive(dir, filename) {
|
|
123251
123620
|
try {
|
|
123252
123621
|
const entries = readdirSync24(dir, { withFileTypes: true, recursive: true });
|
|
123253
123622
|
for (const entry of entries) {
|
|
123254
123623
|
if (entry.isFile() && entry.name === filename) {
|
|
123255
|
-
return
|
|
123624
|
+
return join105(entry.parentPath ?? dir, entry.name);
|
|
123256
123625
|
}
|
|
123257
123626
|
}
|
|
123258
123627
|
} catch (error) {
|
|
@@ -123276,11 +123645,11 @@ function getPlatformKey() {
|
|
|
123276
123645
|
}
|
|
123277
123646
|
function getInstallDir() {
|
|
123278
123647
|
const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
|
|
123279
|
-
return
|
|
123648
|
+
return join105(homeDir, ".cache", CACHE_DIR_NAME, "bin");
|
|
123280
123649
|
}
|
|
123281
123650
|
function getRgPath() {
|
|
123282
123651
|
const isWindows = process.platform === "win32";
|
|
123283
|
-
return
|
|
123652
|
+
return join105(getInstallDir(), isWindows ? "rg.exe" : "rg");
|
|
123284
123653
|
}
|
|
123285
123654
|
async function extractTarGz2(archivePath, destDir) {
|
|
123286
123655
|
const platformKey = getPlatformKey();
|
|
@@ -123297,7 +123666,7 @@ async function extractZip2(archivePath, destDir) {
|
|
|
123297
123666
|
const binaryName = process.platform === "win32" ? "rg.exe" : "rg";
|
|
123298
123667
|
const foundPath = findFileRecursive(destDir, binaryName);
|
|
123299
123668
|
if (foundPath) {
|
|
123300
|
-
const destPath =
|
|
123669
|
+
const destPath = join105(destDir, binaryName);
|
|
123301
123670
|
if (foundPath !== destPath) {
|
|
123302
123671
|
const { renameSync } = await import("fs");
|
|
123303
123672
|
renameSync(foundPath, destPath);
|
|
@@ -123312,13 +123681,13 @@ async function downloadAndInstallRipgrep() {
|
|
|
123312
123681
|
}
|
|
123313
123682
|
const installDir = getInstallDir();
|
|
123314
123683
|
const rgPath = getRgPath();
|
|
123315
|
-
if (
|
|
123684
|
+
if (existsSync86(rgPath)) {
|
|
123316
123685
|
return rgPath;
|
|
123317
123686
|
}
|
|
123318
123687
|
ensureCacheDir(installDir);
|
|
123319
123688
|
const filename = `ripgrep-${RG_VERSION}-${config.platform}.${config.extension}`;
|
|
123320
123689
|
const url = `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/${filename}`;
|
|
123321
|
-
const archivePath =
|
|
123690
|
+
const archivePath = join105(installDir, filename);
|
|
123322
123691
|
try {
|
|
123323
123692
|
await downloadArchive(url, archivePath);
|
|
123324
123693
|
if (config.extension === "tar.gz") {
|
|
@@ -123327,7 +123696,7 @@ async function downloadAndInstallRipgrep() {
|
|
|
123327
123696
|
await extractZip2(archivePath, installDir);
|
|
123328
123697
|
}
|
|
123329
123698
|
ensureExecutable(rgPath);
|
|
123330
|
-
if (!
|
|
123699
|
+
if (!existsSync86(rgPath)) {
|
|
123331
123700
|
throw new Error("ripgrep binary not found after extraction");
|
|
123332
123701
|
}
|
|
123333
123702
|
return rgPath;
|
|
@@ -123343,7 +123712,7 @@ async function downloadAndInstallRipgrep() {
|
|
|
123343
123712
|
}
|
|
123344
123713
|
function getInstalledRipgrepPath() {
|
|
123345
123714
|
const rgPath = getRgPath();
|
|
123346
|
-
return
|
|
123715
|
+
return existsSync86(rgPath) ? rgPath : null;
|
|
123347
123716
|
}
|
|
123348
123717
|
|
|
123349
123718
|
// packages/omo-opencode/src/shared/ripgrep-cli.ts
|
|
@@ -123383,15 +123752,15 @@ function getOpenCodeBundledRg() {
|
|
|
123383
123752
|
const isWindows = process.platform === "win32";
|
|
123384
123753
|
const rgName = isWindows ? "rg.exe" : "rg";
|
|
123385
123754
|
const candidates = [
|
|
123386
|
-
|
|
123387
|
-
|
|
123388
|
-
|
|
123389
|
-
|
|
123390
|
-
|
|
123391
|
-
|
|
123755
|
+
join106(getOpenCodeCacheDir(), "bin", rgName),
|
|
123756
|
+
join106(getDataDir(), "opencode", "bin", rgName),
|
|
123757
|
+
join106(execDir, rgName),
|
|
123758
|
+
join106(execDir, "bin", rgName),
|
|
123759
|
+
join106(execDir, "..", "bin", rgName),
|
|
123760
|
+
join106(execDir, "..", "libexec", rgName)
|
|
123392
123761
|
];
|
|
123393
123762
|
for (const candidate of candidates) {
|
|
123394
|
-
if (
|
|
123763
|
+
if (existsSync87(candidate)) {
|
|
123395
123764
|
return candidate;
|
|
123396
123765
|
}
|
|
123397
123766
|
}
|
|
@@ -124565,9 +124934,9 @@ function createSkillTool(options) {
|
|
|
124565
124934
|
}
|
|
124566
124935
|
var skill = createSkillTool({ directory: process.cwd() });
|
|
124567
124936
|
// packages/omo-opencode/src/tools/session-manager/constants.ts
|
|
124568
|
-
import { join as
|
|
124569
|
-
var TODO_DIR2 =
|
|
124570
|
-
var TRANSCRIPT_DIR2 =
|
|
124937
|
+
import { join as join107 } from "path";
|
|
124938
|
+
var TODO_DIR2 = join107(getClaudeConfigDir(), "todos");
|
|
124939
|
+
var TRANSCRIPT_DIR2 = join107(getClaudeConfigDir(), "transcripts");
|
|
124571
124940
|
var SESSION_LIST_DESCRIPTION = `List all OpenCode sessions with optional filtering.
|
|
124572
124941
|
|
|
124573
124942
|
Returns a list of available session IDs with metadata including message count, date range, and agents used.
|
|
@@ -124640,9 +125009,9 @@ Has Todos: Yes (12 items, 8 completed)
|
|
|
124640
125009
|
Has Transcript: Yes (234 entries)`;
|
|
124641
125010
|
|
|
124642
125011
|
// packages/omo-opencode/src/tools/session-manager/file-storage.ts
|
|
124643
|
-
import { existsSync as
|
|
125012
|
+
import { existsSync as existsSync88 } from "fs";
|
|
124644
125013
|
import { readdir as readdir6, readFile as readFile8 } from "fs/promises";
|
|
124645
|
-
import { join as
|
|
125014
|
+
import { join as join108 } from "path";
|
|
124646
125015
|
|
|
124647
125016
|
// packages/omo-opencode/src/tools/session-manager/directory-filter.ts
|
|
124648
125017
|
import { normalize as normalize4, parse as parse3, sep as sep3 } from "path";
|
|
@@ -124666,7 +125035,7 @@ function ignoreFileStorageError(error) {
|
|
|
124666
125035
|
throw error;
|
|
124667
125036
|
}
|
|
124668
125037
|
async function getFileMainSessions(directory) {
|
|
124669
|
-
if (!
|
|
125038
|
+
if (!existsSync88(SESSION_STORAGE))
|
|
124670
125039
|
return [];
|
|
124671
125040
|
const sessions = [];
|
|
124672
125041
|
try {
|
|
@@ -124674,13 +125043,13 @@ async function getFileMainSessions(directory) {
|
|
|
124674
125043
|
for (const projectDir of projectDirs) {
|
|
124675
125044
|
if (!projectDir.isDirectory())
|
|
124676
125045
|
continue;
|
|
124677
|
-
const projectPath =
|
|
125046
|
+
const projectPath = join108(SESSION_STORAGE, projectDir.name);
|
|
124678
125047
|
const sessionFiles = await readdir6(projectPath);
|
|
124679
125048
|
for (const file of sessionFiles) {
|
|
124680
125049
|
if (!file.endsWith(".json"))
|
|
124681
125050
|
continue;
|
|
124682
125051
|
try {
|
|
124683
|
-
const content = await readFile8(
|
|
125052
|
+
const content = await readFile8(join108(projectPath, file), "utf-8");
|
|
124684
125053
|
const meta = JSON.parse(content);
|
|
124685
125054
|
if (meta.parentID)
|
|
124686
125055
|
continue;
|
|
@@ -124700,7 +125069,7 @@ async function getFileMainSessions(directory) {
|
|
|
124700
125069
|
return sessions.sort((a, b) => b.time.updated - a.time.updated);
|
|
124701
125070
|
}
|
|
124702
125071
|
async function getFileAllSessions() {
|
|
124703
|
-
if (!
|
|
125072
|
+
if (!existsSync88(MESSAGE_STORAGE))
|
|
124704
125073
|
return [];
|
|
124705
125074
|
const sessions = [];
|
|
124706
125075
|
async function scanDirectory(dir) {
|
|
@@ -124709,7 +125078,7 @@ async function getFileAllSessions() {
|
|
|
124709
125078
|
for (const entry of entries) {
|
|
124710
125079
|
if (!entry.isDirectory())
|
|
124711
125080
|
continue;
|
|
124712
|
-
const sessionPath =
|
|
125081
|
+
const sessionPath = join108(dir, entry.name);
|
|
124713
125082
|
const files = await readdir6(sessionPath);
|
|
124714
125083
|
if (files.some((file) => file.endsWith(".json"))) {
|
|
124715
125084
|
sessions.push(entry.name);
|
|
@@ -124730,7 +125099,7 @@ async function fileSessionExists(sessionID) {
|
|
|
124730
125099
|
}
|
|
124731
125100
|
async function getFileSessionMessages(sessionID) {
|
|
124732
125101
|
const messageDir = getMessageDir(sessionID);
|
|
124733
|
-
if (!messageDir || !
|
|
125102
|
+
if (!messageDir || !existsSync88(messageDir))
|
|
124734
125103
|
return [];
|
|
124735
125104
|
const messages = [];
|
|
124736
125105
|
try {
|
|
@@ -124739,7 +125108,7 @@ async function getFileSessionMessages(sessionID) {
|
|
|
124739
125108
|
if (!file.endsWith(".json"))
|
|
124740
125109
|
continue;
|
|
124741
125110
|
try {
|
|
124742
|
-
const content = await readFile8(
|
|
125111
|
+
const content = await readFile8(join108(messageDir, file), "utf-8");
|
|
124743
125112
|
const meta = JSON.parse(content);
|
|
124744
125113
|
const parts = await readParts2(meta.id);
|
|
124745
125114
|
messages.push({
|
|
@@ -124767,8 +125136,8 @@ async function getFileSessionMessages(sessionID) {
|
|
|
124767
125136
|
});
|
|
124768
125137
|
}
|
|
124769
125138
|
async function readParts2(messageID) {
|
|
124770
|
-
const partDir =
|
|
124771
|
-
if (!
|
|
125139
|
+
const partDir = join108(PART_STORAGE, messageID);
|
|
125140
|
+
if (!existsSync88(partDir))
|
|
124772
125141
|
return [];
|
|
124773
125142
|
const parts = [];
|
|
124774
125143
|
try {
|
|
@@ -124777,7 +125146,7 @@ async function readParts2(messageID) {
|
|
|
124777
125146
|
if (!file.endsWith(".json"))
|
|
124778
125147
|
continue;
|
|
124779
125148
|
try {
|
|
124780
|
-
const content = await readFile8(
|
|
125149
|
+
const content = await readFile8(join108(partDir, file), "utf-8");
|
|
124781
125150
|
parts.push(JSON.parse(content));
|
|
124782
125151
|
} catch (error) {
|
|
124783
125152
|
ignoreFileStorageError(error);
|
|
@@ -124791,14 +125160,14 @@ async function readParts2(messageID) {
|
|
|
124791
125160
|
return parts.sort((a, b) => a.id.localeCompare(b.id));
|
|
124792
125161
|
}
|
|
124793
125162
|
async function getFileSessionTodos(sessionID) {
|
|
124794
|
-
if (!
|
|
125163
|
+
if (!existsSync88(TODO_DIR2))
|
|
124795
125164
|
return [];
|
|
124796
125165
|
try {
|
|
124797
125166
|
const allFiles = await readdir6(TODO_DIR2);
|
|
124798
125167
|
const todoFiles = allFiles.filter((file) => file === `${sessionID}.json`);
|
|
124799
125168
|
for (const file of todoFiles) {
|
|
124800
125169
|
try {
|
|
124801
|
-
const content = await readFile8(
|
|
125170
|
+
const content = await readFile8(join108(TODO_DIR2, file), "utf-8");
|
|
124802
125171
|
const data = JSON.parse(content);
|
|
124803
125172
|
if (!Array.isArray(data))
|
|
124804
125173
|
continue;
|
|
@@ -124820,10 +125189,10 @@ async function getFileSessionTodos(sessionID) {
|
|
|
124820
125189
|
return [];
|
|
124821
125190
|
}
|
|
124822
125191
|
async function getFileSessionTranscript(sessionID) {
|
|
124823
|
-
if (!
|
|
125192
|
+
if (!existsSync88(TRANSCRIPT_DIR2))
|
|
124824
125193
|
return 0;
|
|
124825
|
-
const transcriptFile =
|
|
124826
|
-
if (!
|
|
125194
|
+
const transcriptFile = join108(TRANSCRIPT_DIR2, `${sessionID}.jsonl`);
|
|
125195
|
+
if (!existsSync88(transcriptFile))
|
|
124827
125196
|
return 0;
|
|
124828
125197
|
try {
|
|
124829
125198
|
const content = await readFile8(transcriptFile, "utf-8");
|
|
@@ -126685,23 +127054,23 @@ Other built-in agents, custom agents, and task categories are intentionally not
|
|
|
126685
127054
|
|
|
126686
127055
|
Pass \`session_id=<id>\` to continue previous agent with full context. Nested subagent depth is tracked automatically and blocked past the configured limit. Prompts MUST be in English. Use \`background_output\` for async results.`;
|
|
126687
127056
|
// packages/claude-code-compat-core/src/features/claude-code-agent-loader/loader.ts
|
|
126688
|
-
import { existsSync as
|
|
126689
|
-
import { join as
|
|
127057
|
+
import { existsSync as existsSync93, readdirSync as readdirSync25 } from "fs";
|
|
127058
|
+
import { join as join114 } from "path";
|
|
126690
127059
|
|
|
126691
127060
|
// packages/claude-code-compat-core/src/shared/claude-config-dir.ts
|
|
126692
|
-
import { homedir as
|
|
126693
|
-
import { join as
|
|
127061
|
+
import { homedir as homedir22 } from "os";
|
|
127062
|
+
import { join as join109 } from "path";
|
|
126694
127063
|
function getClaudeConfigDir3() {
|
|
126695
127064
|
const envConfigDir = process.env.CLAUDE_CONFIG_DIR;
|
|
126696
127065
|
if (envConfigDir) {
|
|
126697
127066
|
return envConfigDir;
|
|
126698
127067
|
}
|
|
126699
|
-
return
|
|
127068
|
+
return join109(process.env.HOME || process.env.USERPROFILE || homedir22(), ".claude");
|
|
126700
127069
|
}
|
|
126701
127070
|
// packages/claude-code-compat-core/src/shared/opencode-config-dir.ts
|
|
126702
|
-
import { existsSync as
|
|
126703
|
-
import { homedir as
|
|
126704
|
-
import { join as
|
|
127071
|
+
import { existsSync as existsSync89, realpathSync as realpathSync16 } from "fs";
|
|
127072
|
+
import { homedir as homedir23 } from "os";
|
|
127073
|
+
import { join as join110, posix as posix10, resolve as resolve29, win32 as win3211 } from "path";
|
|
126705
127074
|
var TAURI_APP_IDENTIFIER3 = "ai.opencode.desktop";
|
|
126706
127075
|
var TAURI_APP_IDENTIFIER_DEV3 = "ai.opencode.desktop.dev";
|
|
126707
127076
|
function isDevBuild3(version) {
|
|
@@ -126713,15 +127082,15 @@ function getTauriConfigDir3(identifier) {
|
|
|
126713
127082
|
const platform = process.platform;
|
|
126714
127083
|
switch (platform) {
|
|
126715
127084
|
case "darwin":
|
|
126716
|
-
return
|
|
127085
|
+
return join110(homedir23(), "Library", "Application Support", identifier);
|
|
126717
127086
|
case "win32": {
|
|
126718
|
-
const appData = process.env.APPDATA ||
|
|
127087
|
+
const appData = process.env.APPDATA || join110(homedir23(), "AppData", "Roaming");
|
|
126719
127088
|
return win3211.join(appData, identifier);
|
|
126720
127089
|
}
|
|
126721
127090
|
case "linux":
|
|
126722
127091
|
default: {
|
|
126723
|
-
const xdgConfig = process.env.XDG_CONFIG_HOME ||
|
|
126724
|
-
return
|
|
127092
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME || join110(homedir23(), ".config");
|
|
127093
|
+
return join110(xdgConfig, identifier);
|
|
126725
127094
|
}
|
|
126726
127095
|
}
|
|
126727
127096
|
}
|
|
@@ -126730,7 +127099,7 @@ function resolveConfigPath3(pathValue) {
|
|
|
126730
127099
|
return posix10.normalize(pathValue);
|
|
126731
127100
|
}
|
|
126732
127101
|
const resolvedPath = resolve29(pathValue);
|
|
126733
|
-
if (!
|
|
127102
|
+
if (!existsSync89(resolvedPath))
|
|
126734
127103
|
return resolvedPath;
|
|
126735
127104
|
try {
|
|
126736
127105
|
return realpathSync16(resolvedPath);
|
|
@@ -126764,8 +127133,8 @@ function getWslLinuxHomeDir3(windowsConfigRoot) {
|
|
|
126764
127133
|
function getCliDefaultConfigDir3() {
|
|
126765
127134
|
const envXdgConfig = process.env.XDG_CONFIG_HOME?.trim();
|
|
126766
127135
|
const shouldIgnoreWindowsXdg = envXdgConfig !== undefined && envXdgConfig.length > 0 && isWslEnvironment3() && isWindowsUserConfigRoot3(envXdgConfig);
|
|
126767
|
-
const xdgConfig = shouldIgnoreWindowsXdg ? posix10.join(getWslLinuxHomeDir3(envXdgConfig) ?? "/home", ".config") : envXdgConfig ||
|
|
126768
|
-
const configDir = isWslEnvironment3() ? posix10.join(xdgConfig, "opencode") :
|
|
127136
|
+
const xdgConfig = shouldIgnoreWindowsXdg ? posix10.join(getWslLinuxHomeDir3(envXdgConfig) ?? "/home", ".config") : envXdgConfig || join110(homedir23(), ".config");
|
|
127137
|
+
const configDir = isWslEnvironment3() ? posix10.join(xdgConfig, "opencode") : join110(xdgConfig, "opencode");
|
|
126769
127138
|
return resolveConfigPath3(configDir);
|
|
126770
127139
|
}
|
|
126771
127140
|
function getCliCustomConfigDir3() {
|
|
@@ -126798,9 +127167,9 @@ function getOpenCodeConfigDir3(options) {
|
|
|
126798
127167
|
const tauriDir = process.platform === "win32" ? win3211.isAbsolute(tauriDirBase) ? win3211.normalize(tauriDirBase) : win3211.resolve(tauriDirBase) : resolveConfigPath3(tauriDirBase);
|
|
126799
127168
|
if (checkExisting) {
|
|
126800
127169
|
const legacyDir = getCliConfigDir3();
|
|
126801
|
-
const legacyConfig =
|
|
126802
|
-
const legacyConfigC =
|
|
126803
|
-
if (
|
|
127170
|
+
const legacyConfig = join110(legacyDir, "opencode.json");
|
|
127171
|
+
const legacyConfigC = join110(legacyDir, "opencode.jsonc");
|
|
127172
|
+
if (existsSync89(legacyConfig) || existsSync89(legacyConfigC)) {
|
|
126804
127173
|
return legacyDir;
|
|
126805
127174
|
}
|
|
126806
127175
|
}
|
|
@@ -126809,11 +127178,11 @@ function getOpenCodeConfigDir3(options) {
|
|
|
126809
127178
|
// packages/claude-code-compat-core/src/shared/jsonc-parser.ts
|
|
126810
127179
|
init_src();
|
|
126811
127180
|
// packages/claude-code-compat-core/src/shared/resolve-agent-definition-paths.ts
|
|
126812
|
-
import { homedir as
|
|
126813
|
-
import { isAbsolute as isAbsolute16, join as
|
|
127181
|
+
import { homedir as homedir24 } from "os";
|
|
127182
|
+
import { isAbsolute as isAbsolute16, join as join111, resolve as resolve30 } from "path";
|
|
126814
127183
|
function resolveAgentDefinitionPaths(paths, baseDir, containmentDir) {
|
|
126815
127184
|
return paths.flatMap((p) => {
|
|
126816
|
-
const expanded = p.startsWith("~/") ?
|
|
127185
|
+
const expanded = p.startsWith("~/") ? join111(homedir24(), p.slice(2)) : p;
|
|
126817
127186
|
const resolved = isAbsolute16(expanded) ? expanded : resolve30(baseDir, expanded);
|
|
126818
127187
|
if (containmentDir !== null && !isWithinProject(resolved, containmentDir)) {
|
|
126819
127188
|
log4(`agent_definitions path rejected (outside project boundary): ${p} -> ${resolved}`);
|
|
@@ -126841,7 +127210,7 @@ var EXCLUDED_DIR_NAMES2 = [
|
|
|
126841
127210
|
];
|
|
126842
127211
|
var EXCLUDED_DIRS3 = Object.freeze(new Set(EXCLUDED_DIR_NAMES2));
|
|
126843
127212
|
// packages/claude-code-compat-core/src/shared/opencode-command-dirs.ts
|
|
126844
|
-
import { basename as basename15, dirname as dirname38, join as
|
|
127213
|
+
import { basename as basename15, dirname as dirname38, join as join112 } from "path";
|
|
126845
127214
|
function getParentOpencodeConfigDir3(configDir) {
|
|
126846
127215
|
const parentDir = dirname38(configDir);
|
|
126847
127216
|
if (basename15(parentDir) !== "profiles") {
|
|
@@ -126855,21 +127224,21 @@ function getOpenCodeCommandDirs2(options) {
|
|
|
126855
127224
|
...configDirs.flatMap((configDir) => {
|
|
126856
127225
|
const parentConfigDir = getParentOpencodeConfigDir3(configDir);
|
|
126857
127226
|
return [
|
|
126858
|
-
|
|
126859
|
-
|
|
126860
|
-
...parentConfigDir ? [
|
|
127227
|
+
join112(configDir, "commands"),
|
|
127228
|
+
join112(configDir, "command"),
|
|
127229
|
+
...parentConfigDir ? [join112(parentConfigDir, "commands"), join112(parentConfigDir, "command")] : []
|
|
126861
127230
|
];
|
|
126862
127231
|
})
|
|
126863
127232
|
]));
|
|
126864
127233
|
}
|
|
126865
127234
|
// packages/claude-code-compat-core/src/shared/project-discovery-dirs.ts
|
|
126866
127235
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
126867
|
-
import { existsSync as
|
|
126868
|
-
import { dirname as dirname39, join as
|
|
127236
|
+
import { existsSync as existsSync90, realpathSync as realpathSync17 } from "fs";
|
|
127237
|
+
import { dirname as dirname39, join as join113, resolve as resolve31, win32 as win3212 } from "path";
|
|
126869
127238
|
var worktreePathCache3 = new Map;
|
|
126870
127239
|
function normalizePath6(path) {
|
|
126871
127240
|
const resolvedPath = process.platform !== "win32" && win3212.isAbsolute(path) ? path : resolve31(path);
|
|
126872
|
-
if (!
|
|
127241
|
+
if (!existsSync90(resolvedPath)) {
|
|
126873
127242
|
return resolvedPath;
|
|
126874
127243
|
}
|
|
126875
127244
|
try {
|
|
@@ -126924,7 +127293,7 @@ function detectWorktreePath4(directory) {
|
|
|
126924
127293
|
function findGitMarkerAncestor(directory) {
|
|
126925
127294
|
let currentDirectory = normalizePath6(directory);
|
|
126926
127295
|
while (true) {
|
|
126927
|
-
if (
|
|
127296
|
+
if (existsSync90(join113(currentDirectory, ".git"))) {
|
|
126928
127297
|
return currentDirectory;
|
|
126929
127298
|
}
|
|
126930
127299
|
const parentDirectory = dirname39(currentDirectory);
|
|
@@ -126942,8 +127311,8 @@ function findAncestorDirectories3(startDirectory, targetPaths, stopDirectory) {
|
|
|
126942
127311
|
const stopDirectoryKey = resolvedStopDirectory ? pathKey4(resolvedStopDirectory) : undefined;
|
|
126943
127312
|
while (true) {
|
|
126944
127313
|
for (const targetPath of targetPaths) {
|
|
126945
|
-
const candidateDirectory =
|
|
126946
|
-
if (!
|
|
127314
|
+
const candidateDirectory = join113(currentDirectory, ...targetPath);
|
|
127315
|
+
if (!existsSync90(candidateDirectory)) {
|
|
126947
127316
|
continue;
|
|
126948
127317
|
}
|
|
126949
127318
|
const normalizedCandidateDirectory = normalizePath6(candidateDirectory);
|
|
@@ -126972,17 +127341,17 @@ function findProjectOpencodeCommandDirs2(startDirectory, stopDirectory) {
|
|
|
126972
127341
|
], detectedStopDirectory);
|
|
126973
127342
|
}
|
|
126974
127343
|
// packages/claude-code-compat-core/src/features/claude-code-agent-loader/agent-definitions-loader.ts
|
|
126975
|
-
import { existsSync as
|
|
127344
|
+
import { existsSync as existsSync92, readFileSync as readFileSync59 } from "fs";
|
|
126976
127345
|
import { basename as basename16, extname as extname3 } from "path";
|
|
126977
127346
|
|
|
126978
127347
|
// packages/claude-code-compat-core/src/features/claude-code-agent-loader/json-agent-loader.ts
|
|
126979
|
-
import { existsSync as
|
|
127348
|
+
import { existsSync as existsSync91, readFileSync as readFileSync58 } from "fs";
|
|
126980
127349
|
function parseJsonAgentFile(filePath, scope) {
|
|
126981
127350
|
try {
|
|
126982
|
-
if (!
|
|
127351
|
+
if (!existsSync91(filePath)) {
|
|
126983
127352
|
return null;
|
|
126984
127353
|
}
|
|
126985
|
-
const content =
|
|
127354
|
+
const content = readFileSync58(filePath, "utf-8");
|
|
126986
127355
|
const { data } = parseJsoncSafe(content);
|
|
126987
127356
|
if (!data) {
|
|
126988
127357
|
return null;
|
|
@@ -127020,10 +127389,10 @@ function parseJsonAgentFile(filePath, scope) {
|
|
|
127020
127389
|
// packages/claude-code-compat-core/src/features/claude-code-agent-loader/agent-definitions-loader.ts
|
|
127021
127390
|
function parseMarkdownAgentFile(filePath, scope, anthropicProvider) {
|
|
127022
127391
|
try {
|
|
127023
|
-
if (!
|
|
127392
|
+
if (!existsSync92(filePath)) {
|
|
127024
127393
|
return null;
|
|
127025
127394
|
}
|
|
127026
|
-
const content =
|
|
127395
|
+
const content = readFileSync59(filePath, "utf-8");
|
|
127027
127396
|
const { data, body } = parseFrontmatter(content);
|
|
127028
127397
|
const fileName = basename16(filePath);
|
|
127029
127398
|
const agentName = fileName.replace(/\.md$/i, "");
|
|
@@ -127057,7 +127426,7 @@ function parseMarkdownAgentFile(filePath, scope, anthropicProvider) {
|
|
|
127057
127426
|
function loadAgentDefinitions(paths, scope, anthropicProvider) {
|
|
127058
127427
|
const result = Object.create(null);
|
|
127059
127428
|
for (const filePath of paths) {
|
|
127060
|
-
if (!
|
|
127429
|
+
if (!existsSync92(filePath)) {
|
|
127061
127430
|
log4(`[agent-definitions-loader] File not found, skipping: ${filePath}`);
|
|
127062
127431
|
continue;
|
|
127063
127432
|
}
|
|
@@ -127082,7 +127451,7 @@ function loadAgentDefinitions(paths, scope, anthropicProvider) {
|
|
|
127082
127451
|
|
|
127083
127452
|
// packages/claude-code-compat-core/src/features/claude-code-agent-loader/loader.ts
|
|
127084
127453
|
function loadAgentsFromDir(agentsDir, scope, anthropicProvider) {
|
|
127085
|
-
if (!
|
|
127454
|
+
if (!existsSync93(agentsDir)) {
|
|
127086
127455
|
return [];
|
|
127087
127456
|
}
|
|
127088
127457
|
const entries = readdirSync25(agentsDir, { withFileTypes: true });
|
|
@@ -127090,7 +127459,7 @@ function loadAgentsFromDir(agentsDir, scope, anthropicProvider) {
|
|
|
127090
127459
|
for (const entry of entries) {
|
|
127091
127460
|
if (!isMarkdownFile(entry))
|
|
127092
127461
|
continue;
|
|
127093
|
-
const agentPath =
|
|
127462
|
+
const agentPath = join114(agentsDir, entry.name);
|
|
127094
127463
|
const agent = parseMarkdownAgentFile(agentPath, scope, anthropicProvider);
|
|
127095
127464
|
if (agent) {
|
|
127096
127465
|
agents.push(agent);
|
|
@@ -127099,7 +127468,7 @@ function loadAgentsFromDir(agentsDir, scope, anthropicProvider) {
|
|
|
127099
127468
|
return agents;
|
|
127100
127469
|
}
|
|
127101
127470
|
function loadUserAgents(anthropicProvider) {
|
|
127102
|
-
const userAgentsDir =
|
|
127471
|
+
const userAgentsDir = join114(getClaudeConfigDir3(), "agents");
|
|
127103
127472
|
const agents = loadAgentsFromDir(userAgentsDir, "user", anthropicProvider);
|
|
127104
127473
|
const result = Object.create(null);
|
|
127105
127474
|
for (const agent of agents) {
|
|
@@ -127108,7 +127477,7 @@ function loadUserAgents(anthropicProvider) {
|
|
|
127108
127477
|
return result;
|
|
127109
127478
|
}
|
|
127110
127479
|
function loadProjectAgents(directory, anthropicProvider) {
|
|
127111
|
-
const projectAgentsDir =
|
|
127480
|
+
const projectAgentsDir = join114(directory ?? process.cwd(), ".claude", "agents");
|
|
127112
127481
|
const agents = loadAgentsFromDir(projectAgentsDir, "project", anthropicProvider);
|
|
127113
127482
|
const result = Object.create(null);
|
|
127114
127483
|
for (const agent of agents) {
|
|
@@ -127120,7 +127489,7 @@ function loadOpencodeGlobalAgents() {
|
|
|
127120
127489
|
const result = Object.create(null);
|
|
127121
127490
|
const configDirs = getOpenCodeConfigDirs3({ binary: "opencode" });
|
|
127122
127491
|
for (const configDir of configDirs) {
|
|
127123
|
-
const opencodeAgentsDir =
|
|
127492
|
+
const opencodeAgentsDir = join114(configDir, "agents");
|
|
127124
127493
|
const agents = loadAgentsFromDir(opencodeAgentsDir, "opencode");
|
|
127125
127494
|
for (const agent of agents) {
|
|
127126
127495
|
if (!(agent.name in result)) {
|
|
@@ -127131,7 +127500,7 @@ function loadOpencodeGlobalAgents() {
|
|
|
127131
127500
|
return result;
|
|
127132
127501
|
}
|
|
127133
127502
|
function loadOpencodeProjectAgents(directory) {
|
|
127134
|
-
const opencodeProjectDir =
|
|
127503
|
+
const opencodeProjectDir = join114(directory ?? process.cwd(), ".opencode", "agents");
|
|
127135
127504
|
const agents = loadAgentsFromDir(opencodeProjectDir, "opencode-project");
|
|
127136
127505
|
const result = Object.create(null);
|
|
127137
127506
|
for (const agent of agents) {
|
|
@@ -127953,15 +128322,15 @@ function validateArgs(args) {
|
|
|
127953
128322
|
}
|
|
127954
128323
|
|
|
127955
128324
|
// packages/omo-opencode/src/tools/look-at/look-at-input-preparer.ts
|
|
127956
|
-
import { readFileSync as
|
|
128325
|
+
import { readFileSync as readFileSync62 } from "fs";
|
|
127957
128326
|
import { basename as basename17 } from "path";
|
|
127958
128327
|
import { pathToFileURL } from "url";
|
|
127959
128328
|
|
|
127960
128329
|
// packages/omo-opencode/src/tools/look-at/image-converter.ts
|
|
127961
128330
|
import * as childProcess2 from "child_process";
|
|
127962
|
-
import { existsSync as
|
|
128331
|
+
import { existsSync as existsSync95, mkdtempSync, readFileSync as readFileSync61, rmSync as rmSync5, unlinkSync as unlinkSync16, writeFileSync as writeFileSync23 } from "fs";
|
|
127963
128332
|
import { tmpdir as tmpdir7 } from "os";
|
|
127964
|
-
import { dirname as dirname41, join as
|
|
128333
|
+
import { dirname as dirname41, join as join116 } from "path";
|
|
127965
128334
|
var SUPPORTED_FORMATS = new Set([
|
|
127966
128335
|
"image/jpeg",
|
|
127967
128336
|
"image/png",
|
|
@@ -127991,8 +128360,8 @@ var UNSUPPORTED_FORMATS = new Set([
|
|
|
127991
128360
|
var CONVERSION_TIMEOUT_MS = 30000;
|
|
127992
128361
|
function cleanupTemporaryFileAfterFailure(filePath) {
|
|
127993
128362
|
try {
|
|
127994
|
-
if (
|
|
127995
|
-
|
|
128363
|
+
if (existsSync95(filePath)) {
|
|
128364
|
+
unlinkSync16(filePath);
|
|
127996
128365
|
}
|
|
127997
128366
|
} catch (cleanupError) {
|
|
127998
128367
|
const cleanupErrorDescription = cleanupError instanceof Error ? cleanupError.message : String(cleanupError);
|
|
@@ -128009,11 +128378,11 @@ function needsConversion(mimeType) {
|
|
|
128009
128378
|
return mimeType.startsWith("image/");
|
|
128010
128379
|
}
|
|
128011
128380
|
function convertImageToJpeg(inputPath, mimeType) {
|
|
128012
|
-
if (!
|
|
128381
|
+
if (!existsSync95(inputPath)) {
|
|
128013
128382
|
throw new Error(`File not found: ${inputPath}`);
|
|
128014
128383
|
}
|
|
128015
|
-
const tempDir = mkdtempSync(
|
|
128016
|
-
const outputPath =
|
|
128384
|
+
const tempDir = mkdtempSync(join116(tmpdir7(), "opencode-img-"));
|
|
128385
|
+
const outputPath = join116(tempDir, "converted.jpg");
|
|
128017
128386
|
log2(`[image-converter] Converting ${mimeType} to JPEG: ${inputPath}`);
|
|
128018
128387
|
try {
|
|
128019
128388
|
if (process.platform === "darwin") {
|
|
@@ -128023,7 +128392,7 @@ function convertImageToJpeg(inputPath, mimeType) {
|
|
|
128023
128392
|
encoding: "utf-8",
|
|
128024
128393
|
timeout: CONVERSION_TIMEOUT_MS
|
|
128025
128394
|
});
|
|
128026
|
-
if (
|
|
128395
|
+
if (existsSync95(outputPath)) {
|
|
128027
128396
|
log2(`[image-converter] Converted using sips: ${outputPath}`);
|
|
128028
128397
|
return outputPath;
|
|
128029
128398
|
}
|
|
@@ -128039,7 +128408,7 @@ function convertImageToJpeg(inputPath, mimeType) {
|
|
|
128039
128408
|
encoding: "utf-8",
|
|
128040
128409
|
timeout: CONVERSION_TIMEOUT_MS
|
|
128041
128410
|
});
|
|
128042
|
-
if (
|
|
128411
|
+
if (existsSync95(outputPath)) {
|
|
128043
128412
|
log2(`[image-converter] Converted using ImageMagick: ${outputPath}`);
|
|
128044
128413
|
return outputPath;
|
|
128045
128414
|
}
|
|
@@ -128063,11 +128432,11 @@ function convertImageToJpeg(inputPath, mimeType) {
|
|
|
128063
128432
|
function cleanupConvertedImage(filePath) {
|
|
128064
128433
|
try {
|
|
128065
128434
|
const tempDirectory = dirname41(filePath);
|
|
128066
|
-
if (
|
|
128067
|
-
|
|
128435
|
+
if (existsSync95(filePath)) {
|
|
128436
|
+
unlinkSync16(filePath);
|
|
128068
128437
|
log2(`[image-converter] Cleaned up temporary file: ${filePath}`);
|
|
128069
128438
|
}
|
|
128070
|
-
if (
|
|
128439
|
+
if (existsSync95(tempDirectory)) {
|
|
128071
128440
|
rmSync5(tempDirectory, { recursive: true, force: true });
|
|
128072
128441
|
log2(`[image-converter] Cleaned up temporary directory: ${tempDirectory}`);
|
|
128073
128442
|
}
|
|
@@ -128077,18 +128446,18 @@ function cleanupConvertedImage(filePath) {
|
|
|
128077
128446
|
}
|
|
128078
128447
|
}
|
|
128079
128448
|
function convertBase64ImageToJpeg(base64Data, mimeType) {
|
|
128080
|
-
const tempDir = mkdtempSync(
|
|
128449
|
+
const tempDir = mkdtempSync(join116(tmpdir7(), "opencode-b64-"));
|
|
128081
128450
|
const inputExt = mimeType.split("/")[1] || "bin";
|
|
128082
|
-
const inputPath =
|
|
128451
|
+
const inputPath = join116(tempDir, `input.${inputExt}`);
|
|
128083
128452
|
const tempFiles = [inputPath];
|
|
128084
128453
|
try {
|
|
128085
128454
|
const cleanBase64 = base64Data.replace(/^data:[^;]+;base64,/, "");
|
|
128086
128455
|
const buffer = Buffer.from(cleanBase64, "base64");
|
|
128087
|
-
|
|
128456
|
+
writeFileSync23(inputPath, buffer);
|
|
128088
128457
|
log2(`[image-converter] Converting Base64 ${mimeType} to JPEG`);
|
|
128089
128458
|
const outputPath = convertImageToJpeg(inputPath, mimeType);
|
|
128090
128459
|
tempFiles.push(outputPath);
|
|
128091
|
-
const convertedBuffer =
|
|
128460
|
+
const convertedBuffer = readFileSync61(outputPath);
|
|
128092
128461
|
const convertedBase64 = convertedBuffer.toString("base64");
|
|
128093
128462
|
log2(`[image-converter] Base64 conversion successful`);
|
|
128094
128463
|
return { base64: convertedBase64, tempFiles };
|
|
@@ -128118,7 +128487,7 @@ function getTemporaryConversionPath(error) {
|
|
|
128118
128487
|
function readJsonTextPart(filePath) {
|
|
128119
128488
|
let fileContent;
|
|
128120
128489
|
try {
|
|
128121
|
-
fileContent =
|
|
128490
|
+
fileContent = readFileSync62(filePath, "utf-8");
|
|
128122
128491
|
} catch (error) {
|
|
128123
128492
|
const code = error instanceof Error ? Reflect.get(error, "code") : undefined;
|
|
128124
128493
|
if (code === "ENOENT") {
|
|
@@ -132350,7 +132719,7 @@ function isExplicitSyncRun(runInBackground) {
|
|
|
132350
132719
|
return runInBackground === false || runInBackground === "false";
|
|
132351
132720
|
}
|
|
132352
132721
|
// packages/omo-opencode/src/tools/task/task-create.ts
|
|
132353
|
-
import { join as
|
|
132722
|
+
import { join as join118 } from "path";
|
|
132354
132723
|
|
|
132355
132724
|
// packages/omo-opencode/src/tools/task/types.ts
|
|
132356
132725
|
import { z as z54 } from "zod";
|
|
@@ -132405,8 +132774,8 @@ var TaskDeleteInputSchema = z54.object({
|
|
|
132405
132774
|
});
|
|
132406
132775
|
|
|
132407
132776
|
// packages/omo-opencode/src/features/claude-tasks/storage.ts
|
|
132408
|
-
import { join as
|
|
132409
|
-
import { existsSync as
|
|
132777
|
+
import { join as join117, dirname as dirname42, basename as basename18, isAbsolute as isAbsolute17 } from "path";
|
|
132778
|
+
import { existsSync as existsSync96, mkdirSync as mkdirSync21, readFileSync as readFileSync63, writeFileSync as writeFileSync24, renameSync as renameSync8, unlinkSync as unlinkSync17, readdirSync as readdirSync26 } from "fs";
|
|
132410
132779
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
132411
132780
|
function ignoreClaudeTaskStorageError(error) {
|
|
132412
132781
|
if (error instanceof Error)
|
|
@@ -132417,11 +132786,11 @@ function getTaskDir(config = {}) {
|
|
|
132417
132786
|
const tasksConfig = config.sisyphus?.tasks;
|
|
132418
132787
|
const storagePath = tasksConfig?.storage_path;
|
|
132419
132788
|
if (storagePath) {
|
|
132420
|
-
return isAbsolute17(storagePath) ? storagePath :
|
|
132789
|
+
return isAbsolute17(storagePath) ? storagePath : join117(process.cwd(), storagePath);
|
|
132421
132790
|
}
|
|
132422
132791
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
132423
132792
|
const listId = resolveTaskListId(config);
|
|
132424
|
-
return
|
|
132793
|
+
return join117(configDir, "tasks", listId);
|
|
132425
132794
|
}
|
|
132426
132795
|
function sanitizePathSegment(value) {
|
|
132427
132796
|
return value.replace(/[^a-zA-Z0-9_-]/g, "-") || "default";
|
|
@@ -132439,16 +132808,16 @@ function resolveTaskListId(config = {}) {
|
|
|
132439
132808
|
return sanitizePathSegment(basename18(process.cwd()));
|
|
132440
132809
|
}
|
|
132441
132810
|
function ensureDir(dirPath) {
|
|
132442
|
-
if (!
|
|
132443
|
-
|
|
132811
|
+
if (!existsSync96(dirPath)) {
|
|
132812
|
+
mkdirSync21(dirPath, { recursive: true });
|
|
132444
132813
|
}
|
|
132445
132814
|
}
|
|
132446
132815
|
function readJsonSafe(filePath, schema) {
|
|
132447
132816
|
try {
|
|
132448
|
-
if (!
|
|
132817
|
+
if (!existsSync96(filePath)) {
|
|
132449
132818
|
return null;
|
|
132450
132819
|
}
|
|
132451
|
-
const content =
|
|
132820
|
+
const content = readFileSync63(filePath, "utf-8");
|
|
132452
132821
|
const parsed = JSON.parse(content);
|
|
132453
132822
|
const result = schema.safeParse(parsed);
|
|
132454
132823
|
if (!result.success) {
|
|
@@ -132465,12 +132834,12 @@ function writeJsonAtomic(filePath, data) {
|
|
|
132465
132834
|
ensureDir(dir);
|
|
132466
132835
|
const tempPath = `${filePath}.tmp.${Date.now()}`;
|
|
132467
132836
|
try {
|
|
132468
|
-
|
|
132837
|
+
writeFileSync24(tempPath, JSON.stringify(data, null, 2), "utf-8");
|
|
132469
132838
|
renameSync8(tempPath, filePath);
|
|
132470
132839
|
} catch (error) {
|
|
132471
132840
|
try {
|
|
132472
|
-
if (
|
|
132473
|
-
|
|
132841
|
+
if (existsSync96(tempPath)) {
|
|
132842
|
+
unlinkSync17(tempPath);
|
|
132474
132843
|
}
|
|
132475
132844
|
} catch (cleanupError) {
|
|
132476
132845
|
ignoreClaudeTaskStorageError(cleanupError);
|
|
@@ -132500,12 +132869,12 @@ function generateTaskId() {
|
|
|
132500
132869
|
return `T-${randomUUID9()}`;
|
|
132501
132870
|
}
|
|
132502
132871
|
async function acquireLock2(dirPath, options = {}) {
|
|
132503
|
-
const lockPath =
|
|
132872
|
+
const lockPath = join117(dirPath, ".lock");
|
|
132504
132873
|
const lockId = randomUUID9();
|
|
132505
132874
|
const waitTimeoutMs = options.waitTimeoutMs ?? resolveLockWaitTimeoutMs();
|
|
132506
132875
|
const baseRetryDelayMs = options.retryDelayMs ?? DEFAULT_LOCK_RETRY_DELAY_MS;
|
|
132507
132876
|
const createLock = (timestamp) => {
|
|
132508
|
-
|
|
132877
|
+
writeFileSync24(lockPath, JSON.stringify({ id: lockId, timestamp }), {
|
|
132509
132878
|
encoding: "utf-8",
|
|
132510
132879
|
flag: "wx"
|
|
132511
132880
|
});
|
|
@@ -132523,7 +132892,7 @@ async function acquireLock2(dirPath, options = {}) {
|
|
|
132523
132892
|
const reclaimStaleLock = () => {
|
|
132524
132893
|
let snapshot;
|
|
132525
132894
|
try {
|
|
132526
|
-
snapshot =
|
|
132895
|
+
snapshot = readFileSync63(lockPath, "utf-8");
|
|
132527
132896
|
} catch (error) {
|
|
132528
132897
|
ignoreClaudeTaskStorageError(error);
|
|
132529
132898
|
return true;
|
|
@@ -132531,9 +132900,9 @@ async function acquireLock2(dirPath, options = {}) {
|
|
|
132531
132900
|
if (!isStale(snapshot))
|
|
132532
132901
|
return false;
|
|
132533
132902
|
try {
|
|
132534
|
-
if (
|
|
132903
|
+
if (readFileSync63(lockPath, "utf-8") !== snapshot)
|
|
132535
132904
|
return false;
|
|
132536
|
-
|
|
132905
|
+
unlinkSync17(lockPath);
|
|
132537
132906
|
} catch (error) {
|
|
132538
132907
|
ignoreClaudeTaskStorageError(error);
|
|
132539
132908
|
}
|
|
@@ -132583,13 +132952,13 @@ async function acquireLock2(dirPath, options = {}) {
|
|
|
132583
132952
|
acquired: true,
|
|
132584
132953
|
release: () => {
|
|
132585
132954
|
try {
|
|
132586
|
-
if (!
|
|
132955
|
+
if (!existsSync96(lockPath))
|
|
132587
132956
|
return;
|
|
132588
|
-
const lockContent =
|
|
132957
|
+
const lockContent = readFileSync63(lockPath, "utf-8");
|
|
132589
132958
|
const lockData = JSON.parse(lockContent);
|
|
132590
132959
|
if (lockData.id !== lockId)
|
|
132591
132960
|
return;
|
|
132592
|
-
|
|
132961
|
+
unlinkSync17(lockPath);
|
|
132593
132962
|
} catch (error) {
|
|
132594
132963
|
ignoreClaudeTaskStorageError(error);
|
|
132595
132964
|
}
|
|
@@ -132751,7 +133120,7 @@ async function handleCreate(args, config, ctx, context) {
|
|
|
132751
133120
|
threadID: context.sessionID
|
|
132752
133121
|
};
|
|
132753
133122
|
validatedTask = TaskObjectSchema.parse(task);
|
|
132754
|
-
writeJsonAtomic(
|
|
133123
|
+
writeJsonAtomic(join118(taskDir, `${taskId}.json`), validatedTask);
|
|
132755
133124
|
} finally {
|
|
132756
133125
|
lock.release();
|
|
132757
133126
|
}
|
|
@@ -132773,7 +133142,7 @@ async function handleCreate(args, config, ctx, context) {
|
|
|
132773
133142
|
}
|
|
132774
133143
|
}
|
|
132775
133144
|
// packages/omo-opencode/src/tools/task/task-get.ts
|
|
132776
|
-
import { join as
|
|
133145
|
+
import { join as join119 } from "path";
|
|
132777
133146
|
var TASK_ID_PATTERN = /^T-[A-Za-z0-9-]+$/;
|
|
132778
133147
|
function parseTaskId(id) {
|
|
132779
133148
|
if (!TASK_ID_PATTERN.test(id))
|
|
@@ -132798,7 +133167,7 @@ Returns null if the task does not exist or the file is invalid.`,
|
|
|
132798
133167
|
return JSON.stringify({ error: "invalid_task_id" });
|
|
132799
133168
|
}
|
|
132800
133169
|
const taskDir = getTaskDir(config);
|
|
132801
|
-
const taskPath =
|
|
133170
|
+
const taskPath = join119(taskDir, `${taskId}.json`);
|
|
132802
133171
|
const task = readJsonSafe(taskPath, TaskObjectSchema);
|
|
132803
133172
|
return JSON.stringify({ task: task ?? null });
|
|
132804
133173
|
} catch (error) {
|
|
@@ -132811,8 +133180,8 @@ Returns null if the task does not exist or the file is invalid.`,
|
|
|
132811
133180
|
});
|
|
132812
133181
|
}
|
|
132813
133182
|
// packages/omo-opencode/src/tools/task/task-list.ts
|
|
132814
|
-
import { join as
|
|
132815
|
-
import { existsSync as
|
|
133183
|
+
import { join as join120 } from "path";
|
|
133184
|
+
import { existsSync as existsSync97, readdirSync as readdirSync27 } from "fs";
|
|
132816
133185
|
function createTaskList(config) {
|
|
132817
133186
|
return tool({
|
|
132818
133187
|
description: `List all active tasks with summary information.
|
|
@@ -132823,7 +133192,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|
|
132823
133192
|
args: {},
|
|
132824
133193
|
execute: async () => {
|
|
132825
133194
|
const taskDir = getTaskDir(config);
|
|
132826
|
-
if (!
|
|
133195
|
+
if (!existsSync97(taskDir)) {
|
|
132827
133196
|
return JSON.stringify({ tasks: [] });
|
|
132828
133197
|
}
|
|
132829
133198
|
const files = readdirSync27(taskDir).filter((f) => f.endsWith(".json") && f.startsWith("T-")).map((f) => f.replace(".json", ""));
|
|
@@ -132832,7 +133201,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|
|
132832
133201
|
}
|
|
132833
133202
|
const allTasks = [];
|
|
132834
133203
|
for (const fileId of files) {
|
|
132835
|
-
const task = readJsonSafe(
|
|
133204
|
+
const task = readJsonSafe(join120(taskDir, `${fileId}.json`), TaskObjectSchema);
|
|
132836
133205
|
if (task) {
|
|
132837
133206
|
allTasks.push(task);
|
|
132838
133207
|
}
|
|
@@ -132860,7 +133229,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|
|
132860
133229
|
});
|
|
132861
133230
|
}
|
|
132862
133231
|
// packages/omo-opencode/src/tools/task/task-update.ts
|
|
132863
|
-
import { join as
|
|
133232
|
+
import { join as join121 } from "path";
|
|
132864
133233
|
var TASK_ID_PATTERN2 = /^T-[A-Za-z0-9-]+$/;
|
|
132865
133234
|
function parseTaskId2(id) {
|
|
132866
133235
|
if (!TASK_ID_PATTERN2.test(id))
|
|
@@ -132947,7 +133316,7 @@ async function handleUpdate(args, config, ctx, context) {
|
|
|
132947
133316
|
}
|
|
132948
133317
|
let updatedTask = null;
|
|
132949
133318
|
try {
|
|
132950
|
-
updatedTask = applyTaskUpdate(
|
|
133319
|
+
updatedTask = applyTaskUpdate(join121(taskDir, `${taskId}.json`), validatedArgs);
|
|
132951
133320
|
} finally {
|
|
132952
133321
|
lock.release();
|
|
132953
133322
|
}
|
|
@@ -134085,6 +134454,7 @@ function createSessionHooks(args) {
|
|
|
134085
134454
|
pluginConfig
|
|
134086
134455
|
})) : null;
|
|
134087
134456
|
const legacyPluginToast = isHookEnabled("legacy-plugin-toast") ? safeHook("legacy-plugin-toast", () => createLegacyPluginToastHook(ctx)) : null;
|
|
134457
|
+
const nativeEditionNudge = isHookEnabled("native-edition-nudge") ? safeHook("native-edition-nudge", () => createNativeEditionNudgeHook(ctx)) : null;
|
|
134088
134458
|
return {
|
|
134089
134459
|
preemptiveCompaction,
|
|
134090
134460
|
sessionNotification,
|
|
@@ -134108,7 +134478,8 @@ function createSessionHooks(args) {
|
|
|
134108
134478
|
questionLabelTruncator,
|
|
134109
134479
|
taskResumeInfo,
|
|
134110
134480
|
runtimeFallback,
|
|
134111
|
-
legacyPluginToast
|
|
134481
|
+
legacyPluginToast,
|
|
134482
|
+
nativeEditionNudge
|
|
134112
134483
|
};
|
|
134113
134484
|
}
|
|
134114
134485
|
|
|
@@ -134819,7 +135190,7 @@ function createHooks(args) {
|
|
|
134819
135190
|
};
|
|
134820
135191
|
}
|
|
134821
135192
|
// packages/omo-opencode/src/features/background-agent/manager.ts
|
|
134822
|
-
import { join as
|
|
135193
|
+
import { join as join123 } from "path";
|
|
134823
135194
|
|
|
134824
135195
|
// packages/omo-opencode/src/features/background-agent/abort-with-timeout.ts
|
|
134825
135196
|
function getAbortResponseError(response) {
|
|
@@ -135106,8 +135477,8 @@ function writeBackgroundTaskMarker(input) {
|
|
|
135106
135477
|
}
|
|
135107
135478
|
|
|
135108
135479
|
// packages/omo-opencode/src/features/background-agent/compaction-aware-message-resolver.ts
|
|
135109
|
-
import { readdirSync as readdirSync28, readFileSync as
|
|
135110
|
-
import { join as
|
|
135480
|
+
import { readdirSync as readdirSync28, readFileSync as readFileSync64 } from "fs";
|
|
135481
|
+
import { join as join122 } from "path";
|
|
135111
135482
|
function hasFullAgentAndModel(message) {
|
|
135112
135483
|
return !!message.agent && !isCompactionAgent(message.agent) && !!message.model?.providerID && !!message.model?.modelID;
|
|
135113
135484
|
}
|
|
@@ -135191,7 +135562,7 @@ function findNearestMessageExcludingCompaction(messageDir, sessionID) {
|
|
|
135191
135562
|
const messages = [];
|
|
135192
135563
|
for (const file of files) {
|
|
135193
135564
|
try {
|
|
135194
|
-
const content =
|
|
135565
|
+
const content = readFileSync64(join122(messageDir, file), "utf-8");
|
|
135195
135566
|
const parsed = JSON.parse(content);
|
|
135196
135567
|
if (hasCompactionPartInStorage(parsed.id) || isCompactionAgent(parsed.agent)) {
|
|
135197
135568
|
continue;
|
|
@@ -139989,7 +140360,7 @@ The task was re-queued on a fallback model after a retryable failure.
|
|
|
139989
140360
|
parentSessionID: task.parentSessionId
|
|
139990
140361
|
});
|
|
139991
140362
|
}
|
|
139992
|
-
const messageDir =
|
|
140363
|
+
const messageDir = join123(MESSAGE_STORAGE, task.parentSessionId);
|
|
139993
140364
|
const currentMessage = messageDir ? findNearestMessageExcludingCompaction(messageDir, task.parentSessionId) : null;
|
|
139994
140365
|
agent = currentMessage?.agent ?? task.parentAgent;
|
|
139995
140366
|
model = currentMessage?.model?.providerID && currentMessage?.model?.modelID ? { providerID: currentMessage.model.providerID, modelID: currentMessage.model.modelID } : undefined;
|
|
@@ -141668,23 +142039,23 @@ function createMonitorManager(options) {
|
|
|
141668
142039
|
import { createHash as createHash4 } from "crypto";
|
|
141669
142040
|
import {
|
|
141670
142041
|
chmodSync as chmodSync4,
|
|
141671
|
-
existsSync as
|
|
141672
|
-
mkdirSync as
|
|
142042
|
+
existsSync as existsSync100,
|
|
142043
|
+
mkdirSync as mkdirSync22,
|
|
141673
142044
|
readdirSync as readdirSync29,
|
|
141674
|
-
readFileSync as
|
|
142045
|
+
readFileSync as readFileSync66,
|
|
141675
142046
|
renameSync as renameSync10,
|
|
141676
|
-
unlinkSync as
|
|
141677
|
-
writeFileSync as
|
|
142047
|
+
unlinkSync as unlinkSync18,
|
|
142048
|
+
writeFileSync as writeFileSync26
|
|
141678
142049
|
} from "fs";
|
|
141679
|
-
import { basename as basename19, dirname as dirname43, join as
|
|
142050
|
+
import { basename as basename19, dirname as dirname43, join as join126 } from "path";
|
|
141680
142051
|
|
|
141681
142052
|
// packages/mcp-client-core/src/config-dir.ts
|
|
141682
|
-
import { existsSync as
|
|
141683
|
-
import { homedir as
|
|
141684
|
-
import { join as
|
|
142053
|
+
import { existsSync as existsSync98, realpathSync as realpathSync18 } from "fs";
|
|
142054
|
+
import { homedir as homedir25 } from "os";
|
|
142055
|
+
import { join as join124, resolve as resolve32 } from "path";
|
|
141685
142056
|
function resolveConfigPath4(pathValue) {
|
|
141686
142057
|
const resolvedPath = resolve32(pathValue);
|
|
141687
|
-
if (!
|
|
142058
|
+
if (!existsSync98(resolvedPath))
|
|
141688
142059
|
return resolvedPath;
|
|
141689
142060
|
try {
|
|
141690
142061
|
return realpathSync18(resolvedPath);
|
|
@@ -141699,13 +142070,13 @@ function getOpenCodeCliConfigDir(env = process.env) {
|
|
|
141699
142070
|
if (customConfigDir) {
|
|
141700
142071
|
return resolveConfigPath4(customConfigDir);
|
|
141701
142072
|
}
|
|
141702
|
-
const xdgConfigDir = env["XDG_CONFIG_HOME"]?.trim() ||
|
|
141703
|
-
return resolveConfigPath4(
|
|
142073
|
+
const xdgConfigDir = env["XDG_CONFIG_HOME"]?.trim() || join124(homedir25(), ".config");
|
|
142074
|
+
return resolveConfigPath4(join124(xdgConfigDir, "opencode"));
|
|
141704
142075
|
}
|
|
141705
142076
|
|
|
141706
142077
|
// packages/mcp-client-core/src/mcp-oauth/storage-index.ts
|
|
141707
|
-
import { chmodSync as chmodSync3, existsSync as
|
|
141708
|
-
import { join as
|
|
142078
|
+
import { chmodSync as chmodSync3, existsSync as existsSync99, readFileSync as readFileSync65, renameSync as renameSync9, writeFileSync as writeFileSync25 } from "fs";
|
|
142079
|
+
import { join as join125 } from "path";
|
|
141709
142080
|
var INDEX_FILE_NAME = "index.json";
|
|
141710
142081
|
function isTokenIndex(value) {
|
|
141711
142082
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
@@ -141713,14 +142084,14 @@ function isTokenIndex(value) {
|
|
|
141713
142084
|
return Object.values(value).every((entry) => typeof entry === "string");
|
|
141714
142085
|
}
|
|
141715
142086
|
function getIndexPath(storageDir) {
|
|
141716
|
-
return
|
|
142087
|
+
return join125(storageDir, INDEX_FILE_NAME);
|
|
141717
142088
|
}
|
|
141718
142089
|
function readTokenIndex(storageDir) {
|
|
141719
142090
|
const indexPath = getIndexPath(storageDir);
|
|
141720
|
-
if (!
|
|
142091
|
+
if (!existsSync99(indexPath))
|
|
141721
142092
|
return {};
|
|
141722
142093
|
try {
|
|
141723
|
-
const parsed = JSON.parse(
|
|
142094
|
+
const parsed = JSON.parse(readFileSync65(indexPath, "utf-8"));
|
|
141724
142095
|
return isTokenIndex(parsed) ? parsed : {};
|
|
141725
142096
|
} catch (readError) {
|
|
141726
142097
|
if (!(readError instanceof Error))
|
|
@@ -141732,7 +142103,7 @@ function writeTokenIndex(storageDir, index) {
|
|
|
141732
142103
|
try {
|
|
141733
142104
|
const indexPath = getIndexPath(storageDir);
|
|
141734
142105
|
const tempPath = `${indexPath}.tmp.${Date.now()}`;
|
|
141735
|
-
|
|
142106
|
+
writeFileSync25(tempPath, JSON.stringify(index, null, 2), { encoding: "utf-8", mode: 384 });
|
|
141736
142107
|
chmodSync3(tempPath, 384);
|
|
141737
142108
|
renameSync9(tempPath, indexPath);
|
|
141738
142109
|
return true;
|
|
@@ -141750,16 +142121,16 @@ function saveTokenIndexEntry(storageDir, hash, key) {
|
|
|
141750
142121
|
var STORAGE_DIR_NAME = "mcp-oauth";
|
|
141751
142122
|
var LEGACY_STORAGE_FILE_NAME = "mcp-oauth.json";
|
|
141752
142123
|
function getMcpOauthStorageDir() {
|
|
141753
|
-
return
|
|
142124
|
+
return join126(getOpenCodeCliConfigDir(), STORAGE_DIR_NAME);
|
|
141754
142125
|
}
|
|
141755
142126
|
function getMcpOauthServerHash(serverHost, resource) {
|
|
141756
142127
|
return createHash4("sha256").update(buildKey(serverHost, resource)).digest("hex").slice(0, 32);
|
|
141757
142128
|
}
|
|
141758
142129
|
function getMcpOauthStoragePath(serverHost, resource) {
|
|
141759
|
-
return
|
|
142130
|
+
return join126(getMcpOauthStorageDir(), `${getMcpOauthServerHash(serverHost, resource)}.json`);
|
|
141760
142131
|
}
|
|
141761
142132
|
function getLegacyStoragePath() {
|
|
141762
|
-
return
|
|
142133
|
+
return join126(getOpenCodeCliConfigDir(), LEGACY_STORAGE_FILE_NAME);
|
|
141763
142134
|
}
|
|
141764
142135
|
function normalizeHost(serverHost) {
|
|
141765
142136
|
let host = serverHost.trim();
|
|
@@ -141820,10 +142191,10 @@ function isOAuthTokenData(value) {
|
|
|
141820
142191
|
return clientSecret === undefined || typeof clientSecret === "string";
|
|
141821
142192
|
}
|
|
141822
142193
|
function readTokenFile(filePath) {
|
|
141823
|
-
if (!
|
|
142194
|
+
if (!existsSync100(filePath))
|
|
141824
142195
|
return null;
|
|
141825
142196
|
try {
|
|
141826
|
-
const parsed = JSON.parse(
|
|
142197
|
+
const parsed = JSON.parse(readFileSync66(filePath, "utf-8"));
|
|
141827
142198
|
return isOAuthTokenData(parsed) ? parsed : null;
|
|
141828
142199
|
} catch (readError) {
|
|
141829
142200
|
if (!(readError instanceof Error))
|
|
@@ -141833,10 +142204,10 @@ function readTokenFile(filePath) {
|
|
|
141833
142204
|
}
|
|
141834
142205
|
function readLegacyStore() {
|
|
141835
142206
|
const filePath = getLegacyStoragePath();
|
|
141836
|
-
if (!
|
|
142207
|
+
if (!existsSync100(filePath))
|
|
141837
142208
|
return null;
|
|
141838
142209
|
try {
|
|
141839
|
-
const parsed = JSON.parse(
|
|
142210
|
+
const parsed = JSON.parse(readFileSync66(filePath, "utf-8"));
|
|
141840
142211
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
141841
142212
|
return null;
|
|
141842
142213
|
const result = {};
|
|
@@ -141854,11 +142225,11 @@ function readLegacyStore() {
|
|
|
141854
142225
|
function writeTokenFile(filePath, token) {
|
|
141855
142226
|
try {
|
|
141856
142227
|
const dir = dirname43(filePath);
|
|
141857
|
-
if (!
|
|
141858
|
-
|
|
142228
|
+
if (!existsSync100(dir)) {
|
|
142229
|
+
mkdirSync22(dir, { recursive: true });
|
|
141859
142230
|
}
|
|
141860
142231
|
const tempPath = `${filePath}.tmp.${Date.now()}`;
|
|
141861
|
-
|
|
142232
|
+
writeFileSync26(tempPath, JSON.stringify(token, null, 2), { encoding: "utf-8", mode: 384 });
|
|
141862
142233
|
chmodSync4(tempPath, 384);
|
|
141863
142234
|
renameSync10(tempPath, filePath);
|
|
141864
142235
|
return true;
|
|
@@ -147336,16 +147707,16 @@ var WRITE_DEBOUNCE_MS = 250;
|
|
|
147336
147707
|
init_logger2();
|
|
147337
147708
|
|
|
147338
147709
|
// packages/omo-opencode/src/features/tui-sidebar/mirror-io.ts
|
|
147339
|
-
import { mkdirSync as
|
|
147710
|
+
import { mkdirSync as mkdirSync23, readFileSync as readFileSync67 } from "fs";
|
|
147340
147711
|
import { dirname as dirname44 } from "path";
|
|
147341
147712
|
|
|
147342
147713
|
// packages/omo-opencode/src/features/tui-sidebar/mirror-path.ts
|
|
147343
147714
|
import { createHash as createHash6 } from "crypto";
|
|
147344
147715
|
import { realpathSync as realpathSync19 } from "fs";
|
|
147345
|
-
import { homedir as
|
|
147346
|
-
import { join as
|
|
147716
|
+
import { homedir as homedir26 } from "os";
|
|
147717
|
+
import { join as join127, resolve as resolve33 } from "path";
|
|
147347
147718
|
function mirrorStorageDir() {
|
|
147348
|
-
return
|
|
147719
|
+
return join127(process.env.XDG_DATA_HOME ?? join127(homedir26(), ".local", "share"), "opencode", "storage", "oh-my-openagent", MIRROR_DIR_NAME);
|
|
147349
147720
|
}
|
|
147350
147721
|
function canonicalProjectDir(projectDir) {
|
|
147351
147722
|
try {
|
|
@@ -147359,7 +147730,7 @@ function canonicalProjectDir(projectDir) {
|
|
|
147359
147730
|
}
|
|
147360
147731
|
function mirrorFilePath(projectDir) {
|
|
147361
147732
|
const projectHash = createHash6("sha1").update(canonicalProjectDir(projectDir)).digest("hex").slice(0, 16);
|
|
147362
|
-
return
|
|
147733
|
+
return join127(mirrorStorageDir(), `${projectHash}.json`);
|
|
147363
147734
|
}
|
|
147364
147735
|
|
|
147365
147736
|
// packages/omo-opencode/src/features/tui-sidebar/snapshot-schema.ts
|
|
@@ -147412,13 +147783,13 @@ var TuiRuntimeSnapshotSchema = z58.object({
|
|
|
147412
147783
|
function writeMirror(projectDir, snapshot) {
|
|
147413
147784
|
const filePath = mirrorFilePath(projectDir);
|
|
147414
147785
|
const content = JSON.stringify(snapshot);
|
|
147415
|
-
|
|
147786
|
+
mkdirSync23(dirname44(filePath), { recursive: true });
|
|
147416
147787
|
writeFileAtomically2(filePath, content, { mode: 384 });
|
|
147417
147788
|
}
|
|
147418
147789
|
|
|
147419
147790
|
// packages/omo-opencode/src/features/tui-sidebar/loop-reader.ts
|
|
147420
|
-
import { readdirSync as readdirSync30, readFileSync as
|
|
147421
|
-
import { join as
|
|
147791
|
+
import { readdirSync as readdirSync30, readFileSync as readFileSync68, statSync as statSync14 } from "fs";
|
|
147792
|
+
import { join as join128 } from "path";
|
|
147422
147793
|
import { z as z59 } from "zod";
|
|
147423
147794
|
var CriterionSchema = z59.object({
|
|
147424
147795
|
status: z59.string()
|
|
@@ -147448,7 +147819,7 @@ function enumerateCandidates(projectDir) {
|
|
|
147448
147819
|
return [...currentLoopCandidates(projectDir), legacyLoopCandidate(projectDir)].filter((candidate) => candidate !== null);
|
|
147449
147820
|
}
|
|
147450
147821
|
function currentLoopCandidates(projectDir) {
|
|
147451
|
-
const loopRoot =
|
|
147822
|
+
const loopRoot = join128(projectDir, ".omo", "ulw-loop");
|
|
147452
147823
|
let entries;
|
|
147453
147824
|
try {
|
|
147454
147825
|
entries = readdirSync30(loopRoot, { withFileTypes: true });
|
|
@@ -147458,10 +147829,10 @@ function currentLoopCandidates(projectDir) {
|
|
|
147458
147829
|
}
|
|
147459
147830
|
throw error;
|
|
147460
147831
|
}
|
|
147461
|
-
return entries.filter((entry) => entry.isDirectory()).map((entry) => statCandidate(
|
|
147832
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => statCandidate(join128(loopRoot, entry.name, "goals.json"))).filter((candidate) => candidate !== null);
|
|
147462
147833
|
}
|
|
147463
147834
|
function legacyLoopCandidate(projectDir) {
|
|
147464
|
-
return statCandidate(
|
|
147835
|
+
return statCandidate(join128(projectDir, ".omo", "loop", "goals.json"));
|
|
147465
147836
|
}
|
|
147466
147837
|
function statCandidate(path) {
|
|
147467
147838
|
try {
|
|
@@ -147486,7 +147857,7 @@ function readLiveCandidate(candidate) {
|
|
|
147486
147857
|
function readParsedLoop(path) {
|
|
147487
147858
|
let raw;
|
|
147488
147859
|
try {
|
|
147489
|
-
raw = JSON.parse(
|
|
147860
|
+
raw = JSON.parse(readFileSync68(path, "utf8"));
|
|
147490
147861
|
} catch (error) {
|
|
147491
147862
|
if (error instanceof Error) {
|
|
147492
147863
|
return null;
|
|
@@ -150246,40 +150617,40 @@ async function isTmuxAvailableWithDeps(deps) {
|
|
|
150246
150617
|
import {
|
|
150247
150618
|
appendFileSync as appendFileSync6,
|
|
150248
150619
|
chmodSync as chmodSync5,
|
|
150249
|
-
existsSync as
|
|
150620
|
+
existsSync as existsSync102,
|
|
150250
150621
|
renameSync as renameSync11,
|
|
150251
150622
|
statSync as statSync15,
|
|
150252
|
-
unlinkSync as
|
|
150253
|
-
writeFileSync as
|
|
150623
|
+
unlinkSync as unlinkSync19,
|
|
150624
|
+
writeFileSync as writeFileSync27
|
|
150254
150625
|
} from "fs";
|
|
150255
150626
|
|
|
150256
150627
|
// packages/openclaw-core/src/reply-listener-paths.ts
|
|
150257
|
-
import { existsSync as
|
|
150258
|
-
import { homedir as
|
|
150259
|
-
import { join as
|
|
150628
|
+
import { existsSync as existsSync101, mkdirSync as mkdirSync24 } from "fs";
|
|
150629
|
+
import { homedir as homedir27 } from "os";
|
|
150630
|
+
import { join as join129 } from "path";
|
|
150260
150631
|
var REPLY_LISTENER_SECURE_FILE_MODE = 384;
|
|
150261
150632
|
function resolveReplyListenerHomeDir() {
|
|
150262
|
-
return process.env.HOME ?? process.env.USERPROFILE ??
|
|
150633
|
+
return process.env.HOME ?? process.env.USERPROFILE ?? homedir27();
|
|
150263
150634
|
}
|
|
150264
150635
|
function getReplyListenerStateDir() {
|
|
150265
|
-
return
|
|
150636
|
+
return join129(resolveReplyListenerHomeDir(), ".omo", "openclaw", "state");
|
|
150266
150637
|
}
|
|
150267
150638
|
function getReplyListenerPidFilePath() {
|
|
150268
|
-
return
|
|
150639
|
+
return join129(getReplyListenerStateDir(), "reply-listener.pid");
|
|
150269
150640
|
}
|
|
150270
150641
|
function getReplyListenerStateFilePath() {
|
|
150271
|
-
return
|
|
150642
|
+
return join129(getReplyListenerStateDir(), "reply-listener-state.json");
|
|
150272
150643
|
}
|
|
150273
150644
|
function getReplyListenerConfigFilePath() {
|
|
150274
|
-
return
|
|
150645
|
+
return join129(getReplyListenerStateDir(), "reply-listener-config.json");
|
|
150275
150646
|
}
|
|
150276
150647
|
function getReplyListenerLogFilePath() {
|
|
150277
|
-
return
|
|
150648
|
+
return join129(getReplyListenerStateDir(), "reply-listener.log");
|
|
150278
150649
|
}
|
|
150279
150650
|
function ensureReplyListenerStateDir() {
|
|
150280
150651
|
const stateDir = getReplyListenerStateDir();
|
|
150281
|
-
if (!
|
|
150282
|
-
|
|
150652
|
+
if (!existsSync101(stateDir)) {
|
|
150653
|
+
mkdirSync24(stateDir, { recursive: true, mode: 448 });
|
|
150283
150654
|
}
|
|
150284
150655
|
}
|
|
150285
150656
|
|
|
@@ -150292,7 +150663,7 @@ function ignoreReplyListenerLogError(error) {
|
|
|
150292
150663
|
}
|
|
150293
150664
|
function writeSecureReplyListenerFile(filePath, content) {
|
|
150294
150665
|
ensureReplyListenerStateDir();
|
|
150295
|
-
|
|
150666
|
+
writeFileSync27(filePath, content, { mode: REPLY_LISTENER_SECURE_FILE_MODE });
|
|
150296
150667
|
try {
|
|
150297
150668
|
chmodSync5(filePath, REPLY_LISTENER_SECURE_FILE_MODE);
|
|
150298
150669
|
} catch (error) {
|
|
@@ -150301,14 +150672,14 @@ function writeSecureReplyListenerFile(filePath, content) {
|
|
|
150301
150672
|
}
|
|
150302
150673
|
function rotateReplyListenerLogIfNeeded(logPath) {
|
|
150303
150674
|
try {
|
|
150304
|
-
if (!
|
|
150675
|
+
if (!existsSync102(logPath))
|
|
150305
150676
|
return;
|
|
150306
150677
|
const stats = statSync15(logPath);
|
|
150307
150678
|
if (stats.size <= MAX_REPLY_LISTENER_LOG_SIZE_BYTES)
|
|
150308
150679
|
return;
|
|
150309
150680
|
const backupPath = `${logPath}.old`;
|
|
150310
|
-
if (
|
|
150311
|
-
|
|
150681
|
+
if (existsSync102(backupPath)) {
|
|
150682
|
+
unlinkSync19(backupPath);
|
|
150312
150683
|
}
|
|
150313
150684
|
renameSync11(logPath, backupPath);
|
|
150314
150685
|
} catch (error) {
|
|
@@ -150334,7 +150705,7 @@ import { constants as constants24, closeSync as closeSync5, openSync as openSync
|
|
|
150334
150705
|
|
|
150335
150706
|
// packages/openclaw-core/src/session-registry-paths.ts
|
|
150336
150707
|
init_src();
|
|
150337
|
-
import { join as
|
|
150708
|
+
import { join as join130 } from "path";
|
|
150338
150709
|
var SECURE_FILE_MODE = 384;
|
|
150339
150710
|
var MAX_AGE_MS = 24 * 60 * 60 * 1000;
|
|
150340
150711
|
var LOCK_TIMEOUT_MS = 2000;
|
|
@@ -150345,16 +150716,16 @@ var cachedRegistryPaths = null;
|
|
|
150345
150716
|
function resolveRegistryPaths() {
|
|
150346
150717
|
if (cachedRegistryPaths !== null)
|
|
150347
150718
|
return cachedRegistryPaths;
|
|
150348
|
-
const openClawStorageDir =
|
|
150719
|
+
const openClawStorageDir = join130(getOpenCodeStorageDir2(), "openclaw");
|
|
150349
150720
|
cachedRegistryPaths = {
|
|
150350
150721
|
openClawStorageDir,
|
|
150351
|
-
registryPath:
|
|
150352
|
-
registryLockPath:
|
|
150722
|
+
registryPath: join130(openClawStorageDir, "reply-session-registry.jsonl"),
|
|
150723
|
+
registryLockPath: join130(openClawStorageDir, "reply-session-registry.lock")
|
|
150353
150724
|
};
|
|
150354
150725
|
return cachedRegistryPaths;
|
|
150355
150726
|
}
|
|
150356
150727
|
function getOpenCodeStorageDir2() {
|
|
150357
|
-
return
|
|
150728
|
+
return join130(resolveXdgDataDir("opencode"), "opencode", "storage");
|
|
150358
150729
|
}
|
|
150359
150730
|
function getRegistryPath() {
|
|
150360
150731
|
return resolveRegistryPaths().registryPath;
|
|
@@ -150364,11 +150735,11 @@ function getRegistryLockPath() {
|
|
|
150364
150735
|
}
|
|
150365
150736
|
|
|
150366
150737
|
// packages/openclaw-core/src/session-registry-lock.ts
|
|
150367
|
-
import { constants as constants23, closeSync as closeSync4, existsSync as
|
|
150738
|
+
import { constants as constants23, closeSync as closeSync4, existsSync as existsSync104, openSync as openSync4, readFileSync as readFileSync70, statSync as statSync16, unlinkSync as unlinkSync20, writeSync } from "fs";
|
|
150368
150739
|
import { randomUUID as randomUUID12 } from "crypto";
|
|
150369
150740
|
|
|
150370
150741
|
// packages/openclaw-core/src/session-registry-storage.ts
|
|
150371
|
-
import { existsSync as
|
|
150742
|
+
import { existsSync as existsSync103, mkdirSync as mkdirSync25, readFileSync as readFileSync69, writeFileSync as writeFileSync28 } from "fs";
|
|
150372
150743
|
import { dirname as dirname45 } from "path";
|
|
150373
150744
|
function isSessionMapping(value) {
|
|
150374
150745
|
if (typeof value !== "object" || value === null)
|
|
@@ -150391,16 +150762,16 @@ function isSessionMapping(value) {
|
|
|
150391
150762
|
}
|
|
150392
150763
|
function ensureRegistryDir() {
|
|
150393
150764
|
const registryDir = dirname45(getRegistryPath());
|
|
150394
|
-
if (!
|
|
150395
|
-
|
|
150765
|
+
if (!existsSync103(registryDir)) {
|
|
150766
|
+
mkdirSync25(registryDir, { recursive: true, mode: 448 });
|
|
150396
150767
|
}
|
|
150397
150768
|
}
|
|
150398
150769
|
function readAllMappingsUnsafe() {
|
|
150399
150770
|
const registryPath = getRegistryPath();
|
|
150400
|
-
if (!
|
|
150771
|
+
if (!existsSync103(registryPath))
|
|
150401
150772
|
return [];
|
|
150402
150773
|
try {
|
|
150403
|
-
const content =
|
|
150774
|
+
const content = readFileSync69(registryPath, "utf-8");
|
|
150404
150775
|
return content.split(`
|
|
150405
150776
|
`).filter((line) => line.trim()).map((line) => {
|
|
150406
150777
|
try {
|
|
@@ -150422,13 +150793,13 @@ function rewriteRegistryUnsafe(mappings) {
|
|
|
150422
150793
|
ensureRegistryDir();
|
|
150423
150794
|
const registryPath = getRegistryPath();
|
|
150424
150795
|
if (mappings.length === 0) {
|
|
150425
|
-
|
|
150796
|
+
writeFileSync28(registryPath, "", { mode: SECURE_FILE_MODE });
|
|
150426
150797
|
return;
|
|
150427
150798
|
}
|
|
150428
150799
|
const content = mappings.map((mapping) => JSON.stringify(mapping)).join(`
|
|
150429
150800
|
`) + `
|
|
150430
150801
|
`;
|
|
150431
|
-
|
|
150802
|
+
writeFileSync28(registryPath, content, { mode: SECURE_FILE_MODE });
|
|
150432
150803
|
}
|
|
150433
150804
|
|
|
150434
150805
|
// packages/openclaw-core/src/session-registry-lock.ts
|
|
@@ -150451,9 +150822,9 @@ function isPidAlive2(pid) {
|
|
|
150451
150822
|
function readLockSnapshot() {
|
|
150452
150823
|
try {
|
|
150453
150824
|
const registryLockPath = getRegistryLockPath();
|
|
150454
|
-
if (!
|
|
150825
|
+
if (!existsSync104(registryLockPath))
|
|
150455
150826
|
return null;
|
|
150456
|
-
const raw =
|
|
150827
|
+
const raw = readFileSync70(registryLockPath, "utf-8");
|
|
150457
150828
|
const trimmed = raw.trim();
|
|
150458
150829
|
if (!trimmed)
|
|
150459
150830
|
return { raw, pid: null, token: null };
|
|
@@ -150482,12 +150853,12 @@ function readLockSnapshot() {
|
|
|
150482
150853
|
function removeLockIfUnchanged(snapshot) {
|
|
150483
150854
|
try {
|
|
150484
150855
|
const registryLockPath = getRegistryLockPath();
|
|
150485
|
-
if (!
|
|
150856
|
+
if (!existsSync104(registryLockPath))
|
|
150486
150857
|
return false;
|
|
150487
|
-
const currentRaw =
|
|
150858
|
+
const currentRaw = readFileSync70(registryLockPath, "utf-8");
|
|
150488
150859
|
if (currentRaw !== snapshot.raw)
|
|
150489
150860
|
return false;
|
|
150490
|
-
|
|
150861
|
+
unlinkSync20(registryLockPath);
|
|
150491
150862
|
return true;
|
|
150492
150863
|
} catch (error) {
|
|
150493
150864
|
if (error instanceof Error)
|
|
@@ -150505,7 +150876,7 @@ function closeLockFd(fd) {
|
|
|
150505
150876
|
}
|
|
150506
150877
|
function unlinkLockFile() {
|
|
150507
150878
|
try {
|
|
150508
|
-
|
|
150879
|
+
unlinkSync20(getRegistryLockPath());
|
|
150509
150880
|
} catch (error) {
|
|
150510
150881
|
if (error instanceof Error)
|
|
150511
150882
|
return;
|
|
@@ -150633,7 +151004,7 @@ function removeSession(sessionId) {
|
|
|
150633
151004
|
}
|
|
150634
151005
|
|
|
150635
151006
|
// packages/openclaw-core/src/reply-listener-state.ts
|
|
150636
|
-
import { existsSync as
|
|
151007
|
+
import { existsSync as existsSync105, readFileSync as readFileSync71, unlinkSync as unlinkSync21 } from "fs";
|
|
150637
151008
|
var REPLY_LISTENER_STARTUP_TOKEN_ENV = "OMO_OPENCLAW_REPLY_LISTENER_STARTUP_TOKEN";
|
|
150638
151009
|
function ignoreReplyListenerStateReadError(error) {
|
|
150639
151010
|
if (error instanceof Error)
|
|
@@ -150700,9 +151071,9 @@ function createPendingReplyListenerState(startupToken) {
|
|
|
150700
151071
|
function readReplyListenerDaemonState() {
|
|
150701
151072
|
try {
|
|
150702
151073
|
const stateFilePath = getReplyListenerStateFilePath();
|
|
150703
|
-
if (!
|
|
151074
|
+
if (!existsSync105(stateFilePath))
|
|
150704
151075
|
return null;
|
|
150705
|
-
return normalizeReplyListenerState(JSON.parse(
|
|
151076
|
+
return normalizeReplyListenerState(JSON.parse(readFileSync71(stateFilePath, "utf-8")));
|
|
150706
151077
|
} catch (error) {
|
|
150707
151078
|
ignoreReplyListenerStateReadError(error);
|
|
150708
151079
|
return null;
|
|
@@ -150718,9 +151089,9 @@ function writeReplyListenerDaemonState(state) {
|
|
|
150718
151089
|
function readReplyListenerDaemonConfig() {
|
|
150719
151090
|
try {
|
|
150720
151091
|
const configFilePath = getReplyListenerConfigFilePath();
|
|
150721
|
-
if (!
|
|
151092
|
+
if (!existsSync105(configFilePath))
|
|
150722
151093
|
return null;
|
|
150723
|
-
return JSON.parse(
|
|
151094
|
+
return JSON.parse(readFileSync71(configFilePath, "utf-8"));
|
|
150724
151095
|
} catch (error) {
|
|
150725
151096
|
ignoreReplyListenerStateReadError(error);
|
|
150726
151097
|
return null;
|
|
@@ -150732,9 +151103,9 @@ function writeReplyListenerDaemonConfig(config) {
|
|
|
150732
151103
|
function readReplyListenerPid() {
|
|
150733
151104
|
try {
|
|
150734
151105
|
const pidFilePath = getReplyListenerPidFilePath();
|
|
150735
|
-
if (!
|
|
151106
|
+
if (!existsSync105(pidFilePath))
|
|
150736
151107
|
return null;
|
|
150737
|
-
const pid = Number.parseInt(
|
|
151108
|
+
const pid = Number.parseInt(readFileSync71(pidFilePath, "utf-8").trim(), 10);
|
|
150738
151109
|
return Number.isNaN(pid) ? null : pid;
|
|
150739
151110
|
} catch (error) {
|
|
150740
151111
|
ignoreReplyListenerStateReadError(error);
|
|
@@ -150746,8 +151117,8 @@ function writeReplyListenerPid(pid) {
|
|
|
150746
151117
|
}
|
|
150747
151118
|
function removeReplyListenerPid() {
|
|
150748
151119
|
const pidFilePath = getReplyListenerPidFilePath();
|
|
150749
|
-
if (
|
|
150750
|
-
|
|
151120
|
+
if (existsSync105(pidFilePath)) {
|
|
151121
|
+
unlinkSync21(pidFilePath);
|
|
150751
151122
|
}
|
|
150752
151123
|
}
|
|
150753
151124
|
function markReplyListenerStopped(state, error) {
|
|
@@ -150774,7 +151145,7 @@ function getReplyListenerRuntimeSignature(config) {
|
|
|
150774
151145
|
// packages/openclaw-core/src/reply-listener-poll-loop.ts
|
|
150775
151146
|
var PRUNE_INTERVAL_MS = 60 * 60 * 1000;
|
|
150776
151147
|
// packages/openclaw-core/src/reply-listener-start.ts
|
|
150777
|
-
import { dirname as dirname46, join as
|
|
151148
|
+
import { dirname as dirname46, join as join132 } from "path";
|
|
150778
151149
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
150779
151150
|
|
|
150780
151151
|
// packages/openclaw-core/src/reply-listener-spawn.ts
|
|
@@ -150782,8 +151153,8 @@ init_runtime();
|
|
|
150782
151153
|
|
|
150783
151154
|
// packages/openclaw-core/src/reply-listener-process.ts
|
|
150784
151155
|
init_runtime();
|
|
150785
|
-
import { readFileSync as
|
|
150786
|
-
import { join as
|
|
151156
|
+
import { readFileSync as readFileSync72 } from "fs";
|
|
151157
|
+
import { join as join131 } from "path";
|
|
150787
151158
|
var REPLY_LISTENER_DAEMON_IDENTITY_MARKER = "--openclaw-reply-listener-daemon";
|
|
150788
151159
|
var REPLY_LISTENER_DAEMON_ENV_ALLOWLIST = [
|
|
150789
151160
|
"PATH",
|
|
@@ -150819,7 +151190,7 @@ var REPLY_LISTENER_DAEMON_ENV_ALLOWLIST = [
|
|
|
150819
151190
|
];
|
|
150820
151191
|
async function windowsProcessCommandLineHasMarker(pid, deps) {
|
|
150821
151192
|
const systemRoot = process.env.SystemRoot ?? process.env.SYSTEMROOT ?? "C:\\Windows";
|
|
150822
|
-
const powershell =
|
|
151193
|
+
const powershell = join131(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
150823
151194
|
const processInfo = deps.spawn([
|
|
150824
151195
|
powershell,
|
|
150825
151196
|
"-NoProfile",
|
|
@@ -150864,7 +151235,7 @@ async function isReplyListenerDaemonProcessWithDeps(pid, deps) {
|
|
|
150864
151235
|
try {
|
|
150865
151236
|
const platform = deps.platform ?? process.platform;
|
|
150866
151237
|
if (platform === "linux") {
|
|
150867
|
-
const readProcCmdline = deps.readProcCmdline ?? ((targetPid) =>
|
|
151238
|
+
const readProcCmdline = deps.readProcCmdline ?? ((targetPid) => readFileSync72(`/proc/${targetPid}/cmdline`, "utf-8"));
|
|
150868
151239
|
const cmdline = readProcCmdline(pid);
|
|
150869
151240
|
return cmdline.includes(REPLY_LISTENER_DAEMON_IDENTITY_MARKER);
|
|
150870
151241
|
}
|
|
@@ -151036,7 +151407,7 @@ function createStartFailureResult(message, state) {
|
|
|
151036
151407
|
}
|
|
151037
151408
|
function resolveReplyListenerDaemonScript(currentFileUrl) {
|
|
151038
151409
|
const currentFilePath = fileURLToPath7(currentFileUrl);
|
|
151039
|
-
return currentFilePath.endsWith(".ts") ?
|
|
151410
|
+
return currentFilePath.endsWith(".ts") ? join132(dirname46(currentFilePath), "daemon.ts") : join132(dirname46(currentFilePath), "daemon.js");
|
|
151040
151411
|
}
|
|
151041
151412
|
async function startReplyListener(config) {
|
|
151042
151413
|
const normalizedConfig = getNormalizedReplyListenerConfig(config);
|
|
@@ -151459,13 +151830,13 @@ async function createRuntimeSkillSourceServer(options, runtimeEnv = runtime6) {
|
|
|
151459
151830
|
};
|
|
151460
151831
|
}
|
|
151461
151832
|
// packages/claude-code-compat-core/src/features/claude-code-mcp-loader/loader.ts
|
|
151462
|
-
import { existsSync as
|
|
151463
|
-
import { join as
|
|
151464
|
-
import { homedir as
|
|
151833
|
+
import { existsSync as existsSync106, readFileSync as readFileSync73 } from "fs";
|
|
151834
|
+
import { join as join133 } from "path";
|
|
151835
|
+
import { homedir as homedir28 } from "os";
|
|
151465
151836
|
function resolveMcpLoaderContext(options = {}) {
|
|
151466
151837
|
const cwd = options.cwd ?? process.cwd();
|
|
151467
151838
|
const homeDir = options.homeDir ?? getHomeDir();
|
|
151468
|
-
const claudeConfigDir = options.claudeConfigDir ?? (options.homeDir === undefined ? getClaudeConfigDir3() :
|
|
151839
|
+
const claudeConfigDir = options.claudeConfigDir ?? (options.homeDir === undefined ? getClaudeConfigDir3() : join133(homeDir, ".claude"));
|
|
151469
151840
|
return { cwd, homeDir, claudeConfigDir };
|
|
151470
151841
|
}
|
|
151471
151842
|
var mcpLoaderInternals = {
|
|
@@ -151474,17 +151845,17 @@ var mcpLoaderInternals = {
|
|
|
151474
151845
|
function getMcpConfigPaths(context) {
|
|
151475
151846
|
const { claudeConfigDir, homeDir, cwd } = context;
|
|
151476
151847
|
return [
|
|
151477
|
-
{ path:
|
|
151478
|
-
{ path:
|
|
151479
|
-
{ path:
|
|
151480
|
-
{ path:
|
|
151848
|
+
{ path: join133(homeDir, ".claude.json"), scope: "user" },
|
|
151849
|
+
{ path: join133(claudeConfigDir, ".mcp.json"), scope: "user" },
|
|
151850
|
+
{ path: join133(cwd, ".mcp.json"), scope: "project" },
|
|
151851
|
+
{ path: join133(cwd, ".claude", ".mcp.json"), scope: "local" }
|
|
151481
151852
|
];
|
|
151482
151853
|
}
|
|
151483
151854
|
function getHomeDir() {
|
|
151484
|
-
return process.env.HOME || process.env.USERPROFILE ||
|
|
151855
|
+
return process.env.HOME || process.env.USERPROFILE || homedir28();
|
|
151485
151856
|
}
|
|
151486
151857
|
async function loadMcpConfigFile(filePath) {
|
|
151487
|
-
if (!
|
|
151858
|
+
if (!existsSync106(filePath)) {
|
|
151488
151859
|
return null;
|
|
151489
151860
|
}
|
|
151490
151861
|
try {
|
|
@@ -151505,10 +151876,10 @@ function getSystemMcpServerNames(options = {}) {
|
|
|
151505
151876
|
const paths = getMcpConfigPaths(context);
|
|
151506
151877
|
const { cwd } = context;
|
|
151507
151878
|
for (const { path } of paths) {
|
|
151508
|
-
if (!
|
|
151879
|
+
if (!existsSync106(path))
|
|
151509
151880
|
continue;
|
|
151510
151881
|
try {
|
|
151511
|
-
const content =
|
|
151882
|
+
const content = readFileSync73(path, "utf-8");
|
|
151512
151883
|
const config = JSON.parse(content);
|
|
151513
151884
|
if (!config?.mcpServers)
|
|
151514
151885
|
continue;
|
|
@@ -160995,15 +161366,15 @@ function createHephaestusAgent(model, availableAgents, availableToolNames, avail
|
|
|
160995
161366
|
}
|
|
160996
161367
|
createHephaestusAgent.mode = MODE9;
|
|
160997
161368
|
// packages/omo-opencode/src/agents/builtin-agents/resolve-file-uri.ts
|
|
160998
|
-
import { existsSync as
|
|
160999
|
-
import { homedir as
|
|
161000
|
-
import { isAbsolute as isAbsolute18, join as
|
|
161369
|
+
import { existsSync as existsSync107, readFileSync as readFileSync74 } from "fs";
|
|
161370
|
+
import { homedir as homedir29 } from "os";
|
|
161371
|
+
import { isAbsolute as isAbsolute18, join as join134, resolve as resolve34 } from "path";
|
|
161001
161372
|
init_logger2();
|
|
161002
161373
|
var ALLOWED_HOME_SUBDIRS = [
|
|
161003
|
-
|
|
161004
|
-
|
|
161005
|
-
|
|
161006
|
-
|
|
161374
|
+
join134(homedir29(), ".config", "opencode"),
|
|
161375
|
+
join134(homedir29(), ".config", "oh-my-openagent"),
|
|
161376
|
+
join134(homedir29(), ".omo"),
|
|
161377
|
+
join134(homedir29(), ".opencode")
|
|
161007
161378
|
];
|
|
161008
161379
|
function isWithinAllowedPaths(filePath, projectRoot) {
|
|
161009
161380
|
if (isWithinProject(filePath, projectRoot))
|
|
@@ -161021,7 +161392,7 @@ function resolvePromptAppend(promptAppend, configDir) {
|
|
|
161021
161392
|
let filePath;
|
|
161022
161393
|
try {
|
|
161023
161394
|
const decoded = decodeURIComponent(encoded);
|
|
161024
|
-
const expanded = decoded.startsWith("~/") ? decoded.replace(/^~\//, `${
|
|
161395
|
+
const expanded = decoded.startsWith("~/") ? decoded.replace(/^~\//, `${homedir29()}/`) : decoded;
|
|
161025
161396
|
filePath = isAbsolute18(expanded) ? expanded : resolve34(configDir ?? process.cwd(), expanded);
|
|
161026
161397
|
} catch (error) {
|
|
161027
161398
|
if (!(error instanceof Error)) {
|
|
@@ -161039,11 +161410,11 @@ function resolvePromptAppend(promptAppend, configDir) {
|
|
|
161039
161410
|
});
|
|
161040
161411
|
return `[WARNING: Path rejected: ${promptAppend} (resolved outside project root ${projectRoot} and allowed home directories; file:// prompts must reside within the project directory, ~/.config/opencode/, ~/.config/oh-my-openagent/, ~/.omo/, or ~/.opencode/)]`;
|
|
161041
161412
|
}
|
|
161042
|
-
if (!
|
|
161413
|
+
if (!existsSync107(filePath)) {
|
|
161043
161414
|
return `[WARNING: Could not resolve file URI: ${promptAppend}]`;
|
|
161044
161415
|
}
|
|
161045
161416
|
try {
|
|
161046
|
-
return
|
|
161417
|
+
return readFileSync74(filePath, "utf8");
|
|
161047
161418
|
} catch (error) {
|
|
161048
161419
|
if (!(error instanceof Error)) {
|
|
161049
161420
|
throw error;
|
|
@@ -163761,7 +164132,7 @@ async function applyAgentConfig(params) {
|
|
|
163761
164132
|
}
|
|
163762
164133
|
// packages/claude-code-compat-core/src/features/claude-code-command-loader/loader.ts
|
|
163763
164134
|
import { promises as fs21 } from "fs";
|
|
163764
|
-
import { join as
|
|
164135
|
+
import { join as join135, basename as basename21 } from "path";
|
|
163765
164136
|
|
|
163766
164137
|
// packages/claude-code-compat-core/src/features/claude-code-command-loader/loader-cache.ts
|
|
163767
164138
|
var commandLoaderCache = new Map;
|
|
@@ -163809,7 +164180,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
163809
164180
|
continue;
|
|
163810
164181
|
if (entry.name.startsWith("."))
|
|
163811
164182
|
continue;
|
|
163812
|
-
const subDirPath =
|
|
164183
|
+
const subDirPath = join135(commandsDir, entry.name);
|
|
163813
164184
|
const subPrefix = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
163814
164185
|
const subCommands = await loadCommandsFromDir(subDirPath, scope, visited, subPrefix);
|
|
163815
164186
|
commands.push(...subCommands);
|
|
@@ -163817,7 +164188,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
163817
164188
|
}
|
|
163818
164189
|
if (!isMarkdownFile(entry))
|
|
163819
164190
|
continue;
|
|
163820
|
-
const commandPath =
|
|
164191
|
+
const commandPath = join135(commandsDir, entry.name);
|
|
163821
164192
|
const baseCommandName = basename21(entry.name, ".md");
|
|
163822
164193
|
const commandName = prefix ? `${prefix}/${baseCommandName}` : baseCommandName;
|
|
163823
164194
|
try {
|
|
@@ -163880,12 +164251,12 @@ function commandsToRecord(commands) {
|
|
|
163880
164251
|
return result;
|
|
163881
164252
|
}
|
|
163882
164253
|
async function loadUserCommands() {
|
|
163883
|
-
const userCommandsDir =
|
|
164254
|
+
const userCommandsDir = join135(getClaudeConfigDir3(), "commands");
|
|
163884
164255
|
const commands = await loadCommandsFromDir(userCommandsDir, "user");
|
|
163885
164256
|
return commandsToRecord(commands);
|
|
163886
164257
|
}
|
|
163887
164258
|
async function loadProjectCommands(directory) {
|
|
163888
|
-
const projectCommandsDir =
|
|
164259
|
+
const projectCommandsDir = join135(directory ?? process.cwd(), ".claude", "commands");
|
|
163889
164260
|
const commands = await loadCommandsFromDir(projectCommandsDir, "project");
|
|
163890
164261
|
return commandsToRecord(commands);
|
|
163891
164262
|
}
|
|
@@ -164074,7 +164445,7 @@ var grep_app = {
|
|
|
164074
164445
|
};
|
|
164075
164446
|
|
|
164076
164447
|
// packages/omo-opencode/src/mcp/lsp.ts
|
|
164077
|
-
import { existsSync as
|
|
164448
|
+
import { existsSync as existsSync108, readFileSync as readFileSync75 } from "fs";
|
|
164078
164449
|
import { delimiter as delimiter2, dirname as dirname47, resolve as resolve36 } from "path";
|
|
164079
164450
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
164080
164451
|
import { z as z60 } from "zod";
|
|
@@ -164219,7 +164590,7 @@ function findBootstrapRoot(candidates, pathExists) {
|
|
|
164219
164590
|
}
|
|
164220
164591
|
function readDaemonPackageVersion(root) {
|
|
164221
164592
|
try {
|
|
164222
|
-
const packageJson = JSON.parse(
|
|
164593
|
+
const packageJson = JSON.parse(readFileSync75(resolve36(root, PACKAGE_REL, "package.json"), "utf-8"));
|
|
164223
164594
|
return DaemonPackageSchema.parse(packageJson).version;
|
|
164224
164595
|
} catch (error) {
|
|
164225
164596
|
if (!(error instanceof Error))
|
|
@@ -164241,7 +164612,7 @@ function createBootstrapCandidate(root, pathExists, resolveExecutable) {
|
|
|
164241
164612
|
};
|
|
164242
164613
|
}
|
|
164243
164614
|
function resolveLspCommand(options = {}) {
|
|
164244
|
-
const pathExists = options.exists ??
|
|
164615
|
+
const pathExists = options.exists ?? existsSync108;
|
|
164245
164616
|
const resolveExecutable = options.resolveExecutable ?? resolveRuntimeExecutable;
|
|
164246
164617
|
const moduleDirectory = getModuleDirectory(options.moduleUrl ?? import.meta.url);
|
|
164247
164618
|
const candidates = moduleDirectory ? createAncestorCliCandidates({
|
|
@@ -171827,8 +172198,8 @@ function createChatHeadersHandler(args) {
|
|
|
171827
172198
|
}
|
|
171828
172199
|
|
|
171829
172200
|
// packages/omo-opencode/src/plugin/ultrawork-db-model-override.ts
|
|
171830
|
-
import { join as
|
|
171831
|
-
import { existsSync as
|
|
172201
|
+
import { join as join136 } from "path";
|
|
172202
|
+
import { existsSync as existsSync109 } from "fs";
|
|
171832
172203
|
async function importBunSqlite() {
|
|
171833
172204
|
if (typeof globalThis.Bun === "undefined") {
|
|
171834
172205
|
return null;
|
|
@@ -171844,7 +172215,7 @@ async function importBunSqlite() {
|
|
|
171844
172215
|
}
|
|
171845
172216
|
}
|
|
171846
172217
|
function getDbPath() {
|
|
171847
|
-
return
|
|
172218
|
+
return join136(getDataDir(), "opencode", "opencode.db");
|
|
171848
172219
|
}
|
|
171849
172220
|
var MAX_MICROTASK_RETRIES = 10;
|
|
171850
172221
|
function logCaughtDbError(message, metadata, error) {
|
|
@@ -171947,7 +172318,7 @@ async function scheduleDeferredModelOverride(messageId, targetModel, variant) {
|
|
|
171947
172318
|
return;
|
|
171948
172319
|
}
|
|
171949
172320
|
const dbPath = getDbPath();
|
|
171950
|
-
if (!
|
|
172321
|
+
if (!existsSync109(dbPath)) {
|
|
171951
172322
|
log2("[ultrawork-db-override] DB not found, skipping deferred override");
|
|
171952
172323
|
return;
|
|
171953
172324
|
}
|
|
@@ -172801,6 +173172,7 @@ function createEventHookDispatcher(hooks, runEventHookSafely) {
|
|
|
172801
173172
|
await runEventHookSafely("autoUpdateChecker", hooks.autoUpdateChecker?.event, input);
|
|
172802
173173
|
await runEventHookSafely("astGrepSgProvision", hooks.astGrepSgProvision?.event, input);
|
|
172803
173174
|
await runEventHookSafely("legacyPluginToast", hooks.legacyPluginToast?.event, input);
|
|
173175
|
+
await runEventHookSafely("nativeEditionNudge", hooks.nativeEditionNudge?.event, input);
|
|
172804
173176
|
await runEventHookSafely("claudeCodeHooks", hooks.claudeCodeHooks?.event, input);
|
|
172805
173177
|
await runEventHookSafely("backgroundNotificationHook", hooks.backgroundNotificationHook?.event, input);
|
|
172806
173178
|
await runEventHookSafely("sessionNotification", hooks.sessionNotification, input);
|
|
@@ -174664,7 +175036,7 @@ function parseWindowsProcessTable(output) {
|
|
|
174664
175036
|
const entries = Array.isArray(parsed) ? parsed : parsed === undefined ? [] : [parsed];
|
|
174665
175037
|
const processes = [];
|
|
174666
175038
|
for (const entry of entries) {
|
|
174667
|
-
if (!
|
|
175039
|
+
if (!isRecord13(entry))
|
|
174668
175040
|
continue;
|
|
174669
175041
|
const pid = numberField(entry, "ProcessId");
|
|
174670
175042
|
const ppid = numberField(entry, "ParentProcessId");
|
|
@@ -174698,7 +175070,7 @@ function stringField(record, key) {
|
|
|
174698
175070
|
const value = record[key];
|
|
174699
175071
|
return typeof value === "string" ? value : undefined;
|
|
174700
175072
|
}
|
|
174701
|
-
function
|
|
175073
|
+
function isRecord13(value) {
|
|
174702
175074
|
return typeof value === "object" && value !== null;
|
|
174703
175075
|
}
|
|
174704
175076
|
|
|
@@ -174776,9 +175148,9 @@ function processKillErrorMeansAlive(error) {
|
|
|
174776
175148
|
}
|
|
174777
175149
|
|
|
174778
175150
|
// packages/utils/src/process-sweep/lsp-daemon-family.ts
|
|
174779
|
-
import { readFileSync as
|
|
174780
|
-
import { homedir as
|
|
174781
|
-
import { basename as basename23, join as
|
|
175151
|
+
import { readFileSync as readFileSync76, readdirSync as readdirSync31 } from "fs";
|
|
175152
|
+
import { homedir as homedir30 } from "os";
|
|
175153
|
+
import { basename as basename23, join as join137, resolve as resolve37 } from "path";
|
|
174782
175154
|
|
|
174783
175155
|
// packages/utils/src/process-sweep/lsp-daemon-owner-attestation.ts
|
|
174784
175156
|
import { readFile as readFile13 } from "fs/promises";
|
|
@@ -174802,7 +175174,7 @@ async function attestLspDaemonOwner(target, deps = {}) {
|
|
|
174802
175174
|
}
|
|
174803
175175
|
}
|
|
174804
175176
|
function parseLspDaemonOwner(value) {
|
|
174805
|
-
if (!
|
|
175177
|
+
if (!isRecord14(value))
|
|
174806
175178
|
return null;
|
|
174807
175179
|
const pid = value["pid"];
|
|
174808
175180
|
const nonce = value["nonce"];
|
|
@@ -174814,7 +175186,7 @@ function parseLspDaemonOwner(value) {
|
|
|
174814
175186
|
return null;
|
|
174815
175187
|
if (typeof startedAt !== "string" || startedAt.length === 0)
|
|
174816
175188
|
return null;
|
|
174817
|
-
if (!
|
|
175189
|
+
if (!isRecord14(endpoint))
|
|
174818
175190
|
return null;
|
|
174819
175191
|
const kind = endpoint["kind"];
|
|
174820
175192
|
const path = endpoint["path"];
|
|
@@ -174866,7 +175238,7 @@ async function pingLspDaemonOwner(endpoint, authToken) {
|
|
|
174866
175238
|
return finish(null);
|
|
174867
175239
|
try {
|
|
174868
175240
|
const response = JSON.parse(line);
|
|
174869
|
-
if (!
|
|
175241
|
+
if (!isRecord14(response) || response["id"] !== OWNER_PING_REQUEST_ID || "error" in response) {
|
|
174870
175242
|
return finish(null);
|
|
174871
175243
|
}
|
|
174872
175244
|
finish(parseLspDaemonOwner(response["result"]));
|
|
@@ -174879,7 +175251,7 @@ async function pingLspDaemonOwner(endpoint, authToken) {
|
|
|
174879
175251
|
function sameOwner(left, right) {
|
|
174880
175252
|
return left.pid === right.pid && left.nonce === right.nonce && left.startedAt === right.startedAt && left.endpoint.kind === right.endpoint.kind && left.endpoint.path === right.endpoint.path && left.endpoint.dev === right.endpoint.dev && left.endpoint.ino === right.endpoint.ino;
|
|
174881
175253
|
}
|
|
174882
|
-
function
|
|
175254
|
+
function isRecord14(value) {
|
|
174883
175255
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
174884
175256
|
}
|
|
174885
175257
|
|
|
@@ -174894,8 +175266,8 @@ function resolveLspDaemonBaseDir(options = {}) {
|
|
|
174894
175266
|
const override = env[OMO_LSP_DAEMON_DIR_ENV];
|
|
174895
175267
|
if (override !== undefined && override.trim().length > 0)
|
|
174896
175268
|
return resolve37(override);
|
|
174897
|
-
const homeDir = options.homeDir ?? env["HOME"] ?? env["USERPROFILE"] ??
|
|
174898
|
-
return
|
|
175269
|
+
const homeDir = options.homeDir ?? env["HOME"] ?? env["USERPROFILE"] ?? homedir30();
|
|
175270
|
+
return join137(homeDir, ".omo", "lsp-daemon");
|
|
174899
175271
|
}
|
|
174900
175272
|
var VERSION_ENTRY_PATTERN = /^v([A-Za-z0-9][A-Za-z0-9._+-]{0,127})$/;
|
|
174901
175273
|
function listLspDaemonVersionDirs(baseDir) {
|
|
@@ -174914,12 +175286,12 @@ function listLspDaemonVersionDirs(baseDir) {
|
|
|
174914
175286
|
const version = VERSION_ENTRY_PATTERN.exec(entry.name)?.[1];
|
|
174915
175287
|
if (version === undefined)
|
|
174916
175288
|
continue;
|
|
174917
|
-
versions.push({ dir:
|
|
175289
|
+
versions.push({ dir: join137(baseDir, entry.name), version });
|
|
174918
175290
|
}
|
|
174919
175291
|
return versions.sort((left, right) => left.version.localeCompare(right.version));
|
|
174920
175292
|
}
|
|
174921
175293
|
function readLspDaemonOwnerTarget(versionDir) {
|
|
174922
|
-
const ownerPath =
|
|
175294
|
+
const ownerPath = join137(versionDir, "daemon.owner");
|
|
174923
175295
|
let raw;
|
|
174924
175296
|
try {
|
|
174925
175297
|
raw = requireOwnerText(ownerPath);
|
|
@@ -174930,13 +175302,13 @@ function readLspDaemonOwnerTarget(versionDir) {
|
|
|
174930
175302
|
const owner = parseLspDaemonOwner(JSON.parse(raw));
|
|
174931
175303
|
if (owner === null)
|
|
174932
175304
|
return null;
|
|
174933
|
-
return { authPath:
|
|
175305
|
+
return { authPath: join137(versionDir, "daemon.auth"), owner, ownerPath, pid: owner.pid };
|
|
174934
175306
|
} catch {
|
|
174935
175307
|
return null;
|
|
174936
175308
|
}
|
|
174937
175309
|
}
|
|
174938
175310
|
function requireOwnerText(path) {
|
|
174939
|
-
return
|
|
175311
|
+
return readFileSync76(path, "utf8");
|
|
174940
175312
|
}
|
|
174941
175313
|
async function planStaleLspDaemonVersionSweep(options) {
|
|
174942
175314
|
const platform = options.platform ?? process.platform;
|
|
@@ -175003,35 +175375,35 @@ function matchLspDaemonProxyCommand(command, roots, platform) {
|
|
|
175003
175375
|
}
|
|
175004
175376
|
|
|
175005
175377
|
// packages/utils/src/process-sweep/roots.ts
|
|
175006
|
-
import { existsSync as
|
|
175007
|
-
import { homedir as
|
|
175008
|
-
import { join as
|
|
175378
|
+
import { existsSync as existsSync110, readdirSync as readdirSync32, realpathSync as realpathSync20 } from "fs";
|
|
175379
|
+
import { homedir as homedir31 } from "os";
|
|
175380
|
+
import { join as join138, resolve as resolve38 } from "path";
|
|
175009
175381
|
function discoverOmoOwnedRoots(options = {}) {
|
|
175010
175382
|
const env = options.env ?? process.env;
|
|
175011
|
-
const homeDir = options.homeDir ?? env["HOME"] ?? env["USERPROFILE"] ??
|
|
175383
|
+
const homeDir = options.homeDir ?? env["HOME"] ?? env["USERPROFILE"] ?? homedir31();
|
|
175012
175384
|
const roots = new Set;
|
|
175013
|
-
addRoot(roots,
|
|
175385
|
+
addRoot(roots, join138(homeDir, ".claude", "omo"));
|
|
175014
175386
|
addRoot(roots, options.pluginRoot);
|
|
175015
175387
|
for (const root of options.extraRoots ?? [])
|
|
175016
175388
|
addRoot(roots, root);
|
|
175017
|
-
for (const root of readCodexPluginCacheRoots(options.codexHome ?? env["CODEX_HOME"] ??
|
|
175389
|
+
for (const root of readCodexPluginCacheRoots(options.codexHome ?? env["CODEX_HOME"] ?? join138(homeDir, ".codex"))) {
|
|
175018
175390
|
addRoot(roots, root);
|
|
175019
175391
|
}
|
|
175020
175392
|
return [...roots];
|
|
175021
175393
|
}
|
|
175022
175394
|
function readCodexPluginCacheRoots(codexHome) {
|
|
175023
|
-
const cacheRoot =
|
|
175024
|
-
if (!
|
|
175395
|
+
const cacheRoot = join138(codexHome, "plugins", "cache");
|
|
175396
|
+
if (!existsSync110(cacheRoot))
|
|
175025
175397
|
return [];
|
|
175026
175398
|
const roots = [];
|
|
175027
175399
|
for (const publisher of safeReadDir(cacheRoot)) {
|
|
175028
175400
|
if (!OMO_CODEX_PLUGIN_CACHE_PUBLISHERS.has(publisher))
|
|
175029
175401
|
continue;
|
|
175030
|
-
const omoRoot =
|
|
175031
|
-
if (!
|
|
175402
|
+
const omoRoot = join138(cacheRoot, publisher, "omo");
|
|
175403
|
+
if (!existsSync110(omoRoot))
|
|
175032
175404
|
continue;
|
|
175033
175405
|
for (const version of safeReadDir(omoRoot))
|
|
175034
|
-
roots.push(
|
|
175406
|
+
roots.push(join138(omoRoot, version));
|
|
175035
175407
|
}
|
|
175036
175408
|
return roots;
|
|
175037
175409
|
}
|
|
@@ -175069,10 +175441,10 @@ function isNonFatalFsError(error) {
|
|
|
175069
175441
|
var OMO_CODEX_PLUGIN_CACHE_PUBLISHERS = new Set(["sisyphuslabs"]);
|
|
175070
175442
|
|
|
175071
175443
|
// packages/utils/src/process-sweep/sweeper.ts
|
|
175072
|
-
import { join as
|
|
175444
|
+
import { join as join139 } from "path";
|
|
175073
175445
|
|
|
175074
175446
|
// packages/utils/src/process-sweep/family-sweeper.ts
|
|
175075
|
-
import { existsSync as
|
|
175447
|
+
import { existsSync as existsSync111, mkdirSync as mkdirSync26, statSync as statSync17, utimesSync, writeFileSync as writeFileSync29 } from "fs";
|
|
175076
175448
|
import { dirname as dirname48 } from "path";
|
|
175077
175449
|
var DEFAULT_GRACE_MS = 2000;
|
|
175078
175450
|
var DEFAULT_THROTTLE_MS = 60 * 60 * 1000;
|
|
@@ -175164,13 +175536,13 @@ async function safelyKill(pid, context) {
|
|
|
175164
175536
|
}
|
|
175165
175537
|
}
|
|
175166
175538
|
function isSweepThrottled(stampFile, nowMs, throttleMs) {
|
|
175167
|
-
if (!
|
|
175539
|
+
if (!existsSync111(stampFile))
|
|
175168
175540
|
return false;
|
|
175169
175541
|
return nowMs - statSync17(stampFile).mtimeMs < throttleMs;
|
|
175170
175542
|
}
|
|
175171
175543
|
function writeSweepStamp(stampFile, nowMs) {
|
|
175172
|
-
|
|
175173
|
-
|
|
175544
|
+
mkdirSync26(dirname48(stampFile), { recursive: true });
|
|
175545
|
+
writeFileSync29(stampFile, `${new Date(nowMs).toISOString()}
|
|
175174
175546
|
`);
|
|
175175
175547
|
const stampDate = new Date(nowMs);
|
|
175176
175548
|
utimesSync(stampFile, stampDate, stampDate);
|
|
@@ -175186,7 +175558,7 @@ function delay6(ms) {
|
|
|
175186
175558
|
// packages/utils/src/process-sweep/sweeper.ts
|
|
175187
175559
|
var LSP_PROXY_SWEEP_STAMP_FILE = "lsp-proxy-sweep.stamp";
|
|
175188
175560
|
async function sweepOrphanedLspDaemonProxies(options = {}) {
|
|
175189
|
-
const stampFile =
|
|
175561
|
+
const stampFile = join139(resolveLspDaemonBaseDir(options), LSP_PROXY_SWEEP_STAMP_FILE);
|
|
175190
175562
|
const ownedRoots = options.ownedRoots ?? discoverOmoOwnedRoots(options);
|
|
175191
175563
|
const result = await runProcessFamilySweep({
|
|
175192
175564
|
familyLabel: "lsp-daemon proxy sweep",
|
|
@@ -175205,7 +175577,7 @@ async function sweepOrphanedLspDaemonProxies(options = {}) {
|
|
|
175205
175577
|
var LSP_DAEMON_SWEEP_STAMP_FILE = "lsp-daemon-sweep.stamp";
|
|
175206
175578
|
async function sweepStaleLspDaemonVersions(options = {}) {
|
|
175207
175579
|
const baseDir = resolveLspDaemonBaseDir(options);
|
|
175208
|
-
const stampFile =
|
|
175580
|
+
const stampFile = join139(baseDir, LSP_DAEMON_SWEEP_STAMP_FILE);
|
|
175209
175581
|
const currentVersion = resolveCurrentLspDaemonVersion(options);
|
|
175210
175582
|
const dryRun = options.dryRun === true;
|
|
175211
175583
|
if (currentVersion === undefined) {
|
|
@@ -175277,20 +175649,20 @@ function defaultPluginRoot() {
|
|
|
175277
175649
|
// packages/telemetry-core/src/activity-state.ts
|
|
175278
175650
|
init_atomic_write();
|
|
175279
175651
|
init_xdg_data_dir();
|
|
175280
|
-
import { existsSync as
|
|
175281
|
-
import { basename as basename24, join as
|
|
175652
|
+
import { existsSync as existsSync112, mkdirSync as mkdirSync28, readFileSync as readFileSync77 } from "fs";
|
|
175653
|
+
import { basename as basename24, join as join141 } from "path";
|
|
175282
175654
|
|
|
175283
175655
|
// packages/telemetry-core/src/day-claim.ts
|
|
175284
|
-
import { closeSync as closeSync6, mkdirSync as
|
|
175285
|
-
import { join as
|
|
175656
|
+
import { closeSync as closeSync6, mkdirSync as mkdirSync27, openSync as openSync6, readdirSync as readdirSync33, rmSync as rmSync6 } from "fs";
|
|
175657
|
+
import { join as join140 } from "path";
|
|
175286
175658
|
var CLAIM_PREFIX = "daily-active.";
|
|
175287
175659
|
var CLAIM_SUFFIX = ".claim";
|
|
175288
175660
|
function getTelemetryDayClaimFilePath(stateDir, dayUTC) {
|
|
175289
|
-
return
|
|
175661
|
+
return join140(stateDir, `${CLAIM_PREFIX}${dayUTC}${CLAIM_SUFFIX}`);
|
|
175290
175662
|
}
|
|
175291
175663
|
function claimUtcDay(stateDir, dayUTC) {
|
|
175292
175664
|
try {
|
|
175293
|
-
|
|
175665
|
+
mkdirSync27(stateDir, { recursive: true });
|
|
175294
175666
|
closeSync6(openSync6(getTelemetryDayClaimFilePath(stateDir, dayUTC), "wx"));
|
|
175295
175667
|
} catch (error) {
|
|
175296
175668
|
return error.code === "EEXIST" ? "already-claimed" : "unavailable";
|
|
@@ -175312,7 +175684,7 @@ function pruneSupersededClaims(stateDir, dayUTC) {
|
|
|
175312
175684
|
if (!entry.startsWith(CLAIM_PREFIX) || !entry.endsWith(CLAIM_SUFFIX))
|
|
175313
175685
|
continue;
|
|
175314
175686
|
try {
|
|
175315
|
-
rmSync6(
|
|
175687
|
+
rmSync6(join140(stateDir, entry), { force: true });
|
|
175316
175688
|
} catch {}
|
|
175317
175689
|
}
|
|
175318
175690
|
}
|
|
@@ -175325,14 +175697,14 @@ function resolveTelemetryStateDir(product, options = {}) {
|
|
|
175325
175697
|
env: options.env,
|
|
175326
175698
|
osProvider: options.osProvider
|
|
175327
175699
|
});
|
|
175328
|
-
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined :
|
|
175700
|
+
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined : join141(options.env.XDG_DATA_HOME, product.cacheDirName);
|
|
175329
175701
|
if (dataDir === xdgStateDir || xdgStateDir === undefined && basename24(dataDir) === product.cacheDirName) {
|
|
175330
175702
|
return dataDir;
|
|
175331
175703
|
}
|
|
175332
|
-
return
|
|
175704
|
+
return join141(dataDir, product.cacheDirName);
|
|
175333
175705
|
}
|
|
175334
175706
|
function getTelemetryActivityStateFilePath(stateDir) {
|
|
175335
|
-
return
|
|
175707
|
+
return join141(stateDir, POSTHOG_ACTIVITY_STATE_FILE);
|
|
175336
175708
|
}
|
|
175337
175709
|
function getDailyActiveCaptureState(input) {
|
|
175338
175710
|
const dayUTC = getUtcDayString(input.now ?? new Date);
|
|
@@ -175365,11 +175737,11 @@ function isPostHogActivityState(value) {
|
|
|
175365
175737
|
}
|
|
175366
175738
|
function readPostHogActivityState(stateDir, diagnostics) {
|
|
175367
175739
|
const stateFilePath = getTelemetryActivityStateFilePath(stateDir);
|
|
175368
|
-
if (!
|
|
175740
|
+
if (!existsSync112(stateFilePath)) {
|
|
175369
175741
|
return {};
|
|
175370
175742
|
}
|
|
175371
175743
|
try {
|
|
175372
|
-
const stateContent =
|
|
175744
|
+
const stateContent = readFileSync77(stateFilePath, "utf-8");
|
|
175373
175745
|
const stateJson = JSON.parse(stateContent);
|
|
175374
175746
|
if (!isPostHogActivityState(stateJson)) {
|
|
175375
175747
|
return {};
|
|
@@ -175388,7 +175760,7 @@ function readPostHogActivityState(stateDir, diagnostics) {
|
|
|
175388
175760
|
function writePostHogActivityState(stateDir, nextState, diagnostics) {
|
|
175389
175761
|
const stateFilePath = getTelemetryActivityStateFilePath(stateDir);
|
|
175390
175762
|
try {
|
|
175391
|
-
|
|
175763
|
+
mkdirSync28(stateDir, { recursive: true });
|
|
175392
175764
|
writeFileAtomically(stateFilePath, `${JSON.stringify(nextState, null, 2)}
|
|
175393
175765
|
`);
|
|
175394
175766
|
} catch (error) {
|
|
@@ -182656,7 +183028,7 @@ var TOPLEVEL_SENTINELS = [
|
|
|
182656
183028
|
field: "window_id"
|
|
182657
183029
|
}
|
|
182658
183030
|
];
|
|
182659
|
-
function
|
|
183031
|
+
function isRecord15(value) {
|
|
182660
183032
|
return typeof value == "object" && value !== null && !Array.isArray(value);
|
|
182661
183033
|
}
|
|
182662
183034
|
function toRfc3339(timestamp) {
|
|
@@ -182678,7 +183050,7 @@ function relocateInto(properties, key, value) {
|
|
|
182678
183050
|
properties[key] = value;
|
|
182679
183051
|
}
|
|
182680
183052
|
function buildV1Event(message) {
|
|
182681
|
-
const sourceProperties =
|
|
183053
|
+
const sourceProperties = isRecord15(message.properties) ? message.properties : {};
|
|
182682
183054
|
const properties = {
|
|
182683
183055
|
...sourceProperties
|
|
182684
183056
|
};
|