# Yunke App session — bounded read-only client

Part of the [AI Voice Agent](/docs/modules_handbook/shared/voice-agent/readMe.md).
Uses ordinary App login and a short-lived in-memory token. The independent
[offline batch-task protocol](/docs/modules_handbook/shared/voice-agent/yunke-app-tasks-offline.md)
has no sending transport. Built 2026-10-24; minimal dev-chen baseline imported 2026-10-25.

## What it does

Reads **one page of tasks, historical recording metadata, results or interested customers**,
or the **unpaged intention-tag catalog**. The PHP client also reads **one recording
detail/transcript for an explicit per-call ID**. The Yunke switches remain off by default.
No `ConversationalCaller` implementation or binding: the existing outbound caller is unchanged.
No tasks, calls, recordings, CRM rows, webhook settlement,
queues, schedules or notifications are created or updated. `recordFile` is never downloaded.
The separately disabled [result processor](/docs/modules_handbook/shared/voice-agent/yunke-app-results.md)
can consume this reader's explicit bound-call bundle and persist supported results;
the reader itself still performs no writes.

Implementation tests use **synthetic fixtures**, built from observed App shapes and static DTOs.
The earlier 2026-10-24 reads selected a personal identity, previously mislabeled as enterprise:
they returned empty tasks/results/interested lists, three history rows and five tags.
Separate 2026-10-25 reads verified the enterprise identity, C1 recording details and the four
lists below. A later explicitly authorized single-number task produced the real result
sample described next; committed test fixtures remain synthetic, and the interested list
still has no nonempty sample. This is not a verified full AI results feed. This baseline
imports no V3 task client, webhook receiver or outbound provider routing. A separate
[Web-session reader and explicit auto-binder](/docs/modules_handbook/shared/voice-agent/yunke-web-results.md)
are now locally adapted behind disabled flags; this App reader still performs no writes.

Evidence version: APK 2.0.20 / versionCode 20020 / `com.yunke.aioutbound`, SHA-256
`100ffdb27f72b96f82013314e2eb73fe8b4e0501746811c173eb41d3c1f36bc9`.

## Authorized single-number task sample S2 (2026-10-25)

The user separately approved exactly one owner-number task. An isolated Mac process
used dev-chen's pure `YunkeAppTaskAdapter` to build `/aiCallOut/save`, sent it with the
phone's restored, fingerprint-verified enterprise session, and parsed the literal
string task ID with the same adapter. This was an API create followed by the phone's
native scheduled-task loop, not an ADB dial or production funnel execution. Persistent
Yunke flags and runtime files stayed unchanged. The probe performed no new App login
while the phone participated. The later App/Web comparison below establishes the
fresh-App-login conflict and a short Web coexistence observation.

Times below are Asia/Kuala_Lumpur on 2026-10-25:

| Observation | Evidence / limit |
| --- | --- |
| Exactly one task and recipient | One create attempt, one returned task ID; one explicit child row matched the approved number and parent. `redialCount=0`. |
| Native scheduling | Created 04:42:30, resumed 04:45:32, native dial logged 04:54:34. About nine minutes from resume to dial; no immediate-dial guarantee. |
| Recipient / SIM | App's native logs matched the exact approved number. Only MY SIM slot 1 became active. Android Telecom redacted its handle, so that dump alone did not verify the number. |
| Audio | User confirmed success; cloud recording duration 28305 ms, three transcript segments (two channel 0, one channel 1). No audio was downloaded. |
| Transcript timing | Final endTime 30750 exceeds duration by 2445 ms; preserve the discrepancy. |
| Stop / final state | Pause was read-confirmed at first dial, 04:54:38. After result upload, taskStatus was 4 and isPaused was 0; another pause returned code 20000, "Only not-started or in-progress tasks can be operated on". App was force-stopped and both SIMs verified idle. Do not infer a running queue from isPaused alone, or claim final paused=true. |

The explicit S2 chain is:

- Create response -> taskDetail.id -> taskDetailPage parent taskId and child row.id.
- Native upload payloads explicitly link that child to callActionId, including the
  known `turnOnTimeCallDuration` request's id=child and callId=per-call ID.
- `getFilterTaskList` returned one row: its taskId matched the created task and its
  **id matched the independently established callActionId**, not the child row.id.
- History returned ten rows, one exact id match; `getRecordingByCallId` echoed that
  same per-call ID and the verified company/user. Interested page 1 remained empty,
  with no total supplied. No phone/time matching was used.

App taskDetailPage did **not** supply callId/callActionId. Do not feed its row, or the
different result-list row, into the existing Web-row inspector as if the shapes were
interchangeable. The native-log child/per-call link is evidence for this sample. Later
Web reads verified that interface's explicit child/call link; the App list shape remains unchanged.

S2's successful passive analysis response carried the exact callActionId and identity:
summary length 144, intentLevel `未明确`, raw intentSignal 25. A subsequent read of the
same history row returned remark exactly equal to that summary and tipType 7 / tipName
`未明确`. This verifies a summary readback for S2 without invoking analysis. It does not
prove history exposes every structured analysis field or guarantees eventual delivery.
`aiAnalysis` on task/result rows was an integer flag. Raw callStatus was 3 there and
1 in history; isReceive=0 and isAiAnswer=0 coexisted with audible AI and a customer
transcript segment. Keep endpoint-specific meanings; do not derive terminal outcomes,
human participation or normalized intent from these numbers alone.

No petaV3 call/lead was created, settled or notified during S2. At that time, missing steps were
durable local UUID/task/subtask/per-attempt bindings, ordinary session lifecycle without
disrupting the phone, verified status/cancellation semantics, repeated/late result
handling, and integration with the shared call aftermath. No further live task or
customer call is authorized by this historical sample.

## Live session comparison and Web result chain (2026-10-25)

A separately authorized read-only test used the same completed S2 task. A new App
login invalidated the phone's previously working token: code -10000 / success=false,
"token incorrect". A single login per result bundle still causes this conflict.
**Keep the fresh-App-login collector disabled; do not schedule it against an active phone.**

After the user restored the phone's enterprise login and authenticated box, normal
Web pcLogin coexisted with the same phone token for a measured 131-second window.
The phone's task query succeeded before, immediately after and at the end; its cached
token did not change. Four snapshots remained on the App main activity with the box
connected/authenticated and phone idle. Long-running, lock-screen and renewal behavior
were not tested. Web cookies were kept only in memory, with no App token used on Web routes.

Web taskDetailPage explicitly returned taskId, id (child) and callId (per-call) in one
row. Its decoded aiRawResult.callActionId equalled callId and the independently known
S2 callActionId. In this sample aiRawResult.tsdId was also the per-call ID, not a child ID.
Web callDetail for the returned child/call pair had no response ID echoes, but its
28305 ms, three-segment transcript matched S2's hash exactly. Its 144-character
dialogueSummary equalled the result's summary; structured intentLevel was "未明确"
with raw intentSignal 25. No analysis-generation endpoint was invoked.

This verifies a cloud source for explicit S2 IDs and structured analysis. It does not
make the App and Web row shapes interchangeable or establish every redial's retention.
Subsequent local work added a disabled, fake-tested Web reader/auto-binder; no real result
was ingested or written back. See [processing evidence and limits](/docs/modules_handbook/shared/voice-agent/yunke-app-results.md).

## Verified enterprise identity and C1 (2026-10-25)

For the later interrupted owner run, a separately authorized read-only follow-up found
code 20000 (`recording record not found`) for that exact action ID while S2 still returned
10000 using the same existing phone session and identity. Thus a query_failed result need
not mean wrong identity; this call's incomplete post-call media/analysis flow is separately
documented in the [owner-test follow-up](/docs/modules_handbook/shared/voice-agent/yunke-owner-acceptance.md).
No App login, result writeback or recording download was performed in that follow-up.

The diagnostic script had selected `company=personal` (`userType=0` in this account),
then incorrectly called it enterprise. Its C1 detail read returned HTTP 200,
`code=20000`, `success=false`, with the redacted message "Recording record not found";
the client correctly raised `query_failed`. Normal login using this same account's
non-personal enterprise identity (`userType=1` here) returned C1 with `code=10000`.
The selected company and user, login response and outgoing headers matched exactly;
the successful recording response explicitly carried the same company and user.
The URL, known C1 request body and nonsecret headers were unchanged between these reads.

These userType values describe the observed account, not a universal identity selector.
Select an explicitly verified `companyCode`/`userId`, never an array position, role guess or
automatic fallback. The four-list probe required both identity fingerprints to equal
those from the successful C1 enterprise read before proceeding.

| Enterprise query | Scope | Returned | Total / pages |
| --- | --- | --- | --- |
| tasks | page 1, pageSize 30 | 0 rows | 0 / 0 |
| results | page 1, pageSize 30 | 0 rows | 0 / 0 |
| interested | page 1, pageSize 30 | 0 rows | Not supplied; retain null |
| history | page 1, pageSize 30 | 9 rows | 9 / 1 |

All 13 requests in that probe (one identity discovery plus four client auth/query
sequences) returned HTTP 200 and integer/string `code=10000`. No authentication failure
was consumed as an empty page. Correcting the identity did not produce nonempty task,
result or interested-customer lists. The interested response has no total; the finding
is limited to the requested empty first page. The earlier three-row history and this
nine-row history were observed at different times; their count difference alone does
not establish an identity effect.

The verified per-call chain is **independently known C1 callActionId -> history.id ->
recording detail.callId**. Only the first history row matched C1 byte-exactly. That row
supplied none of `taskId`, `subTaskId`, `taskSubId`, `callActionId`, `actionId` or `callId`.
This does not license treating arbitrary history IDs as callActionIds or task IDs.

The successful enterprise recording read returned 129553 ms and 19 transcript segments
(10 channel 0, 9 channel 1), with canonical SHA-256
`c65894bd92f7c24b018d3f265a331093b070d119b04576d43699bcc095bc046c`, identical to the
earlier C1 response. Last endTime remains 136070 ms: preserve the 6517 ms overrun and
`end_exceeds_duration`. The URL was metadata only. The old App token was not retained,
so no byte-for-byte old-token comparison was performed.

Summary and medium-intent evidence came from a separately observed successful App
analysis response, not this recording getter. C1's history tag and the analysis intent
are different namespaces; do not normalize them by numeric code equality. The later S2
Web result read verified structured task-linked summary/intent retrieval; it does not
give the manual C1 sample a task association.

### Task samples missing before S2

- One existing nonempty AI task in the verified enterprise, with an explicit taskId
  and the relevant subtask ID returned by a supported read.
- A result for that task explicitly linking the subtask to its callActionId, plus
  recording/analysis evidence for that same call. C1 is a manual-call sample and does
  not currently establish this task chain.
- A trusted external UUID or explicit mapping to the originating petaV3 call, and
  verified terminal-status semantics, before any settlement or aftermath is enabled.

S2 above partly fills this historical checklist; C1 itself still has no task link.
Use existing records or vendor-provided redacted samples for remaining gaps. This
checklist authorizes no task creation, calls, analysis generation, recording downloads
or automatic writeback.
Unmatched rows remain isolated. The live probes used process-only configuration and
did not boot the full Laravel app, database, queues, scheduler, notifications or Inspector.
Persistent Yunke flags stayed off; no credentials, raw IDs, tokens, recording URLs or speech were
added to this handbook. Restored wireless ADB is separate from provider enablement.

## Bound-call collection added after S2

`readCallResult($taskId, $callActionId)` performs one existing authentication sequence,
then reads results page 1/30, history page 1/30 and the explicit recording detail.
Only the exact result id and taskId are accepted; no match returns
`not_found_on_requested_page` without further reads. Matching history is optional for
late summaries, but authentication failures and duplicate/conflicting IDs throw.
The returned identity comes from verified login, never a row claim. No token is returned.
It neither discovers subtask bindings nor extends the console resource list, and is
not a scheduled worker. See [processing and limits](/docs/modules_handbook/shared/voice-agent/yunke-app-results.md).

## How it works

1. Validate pagination before HTTP (page at least 1, page size 1–30, default 1).
   Tags have no pagination; the command rejects nondefault page/page-size options for them.
   `services.yunke_app_read.enabled` must be true and credentials/target company must be present.
   False/off/no are disabled. `services.yunke.enabled` has no effect on App reads.
2. `POST https://ykphone.yunkecn.com/newuc/login/checkAndGetUsers` with `source:aiphonecallapp`
   and ordinary JSON `{account,passwdEncrypt:false,passwd,scope:"all",method:"PASSWD"}`.
   The raw password goes only to that fixed HTTPS endpoint. Select the explicitly configured
   `companyCode`; no first-item/domain/role guessing. If ambiguous, require an explicit `user_id`.
   A nonempty IMEI restriction is refused without spoofing a device identifier.
3. Validate the selected `ykPhoneDomain` as the observed HTTPS **phone3.yunkecn.com** origin,
   trimming whitespace and dropping its path. Reject userinfo/query/fragment and ports other than
   443; never follow redirects. No configurable arbitrary host or TLS bypass exists.
4. `POST /usercenter/login/appLogin` on that fixed origin. The APK password transform is
   DES/CBC/PKCS5Padding, key first 8 UTF-8 bytes of `login.security@yunkecn`, IV `12345678`, standard
   Base64. OpenSSL equal-key DES-EDE3-CBC gives the equivalent result without a global crypto
   setting change. The final login must return the selected user and company. Only missing/null/empty
   login company becomes `personal`, which must itself be the explicitly selected identity.
5. Query one fixed endpoint with raw `token`, verified `userId`/`company`, `ykcode:20020`,
   `version:2.0.20`, `package:com.yunke.aioutbound`, `Accept-Language:zh-CN`, `pt:202`.
   All requests are normal JSON over TLS, timeout 10 seconds, connect timeout 5 seconds.
   There is no V3 envelope/signature, retry, auto-pagination, token refresh or re-login.

| Resource | POST path / request | Exact response data |
|---|---|---|
| tasks | `/phone-ai-call/app/aiCallOut/taskPage` / `{page,pageSize,companyCode}` | `data.data` array, `totalCount`, `pageCount`, `page`, `pageSize` |
| history | `/phone-ai-call/app/index/getUserCallHistory` / `{pageNum,pageSize}` | `data.callRecordlist` array (lowercase l), `dataCount`, `totalPage` |
| results | `/phone-ai-call/app/index/getFilterTaskList` / `{pageNum,pageSize}` | `data.list` array, `total`, `pages`, `pageNum`, `pageSize` |
| interested | `/phone-ai-call/app/index/getInterestedCustomerList` / `{pageNum,pageSize}` | `data` array; no total or page count |
| tags | `/phone-ai-call/app/tag/getSystemTags` / `{tagType:1}` | `data` array; unpaged catalog |

The console exposes only these five business queries. The PHP-only recording getter below adds
one fixed business query; it does not extend the console resource list. Results and
interested-customer reads use one requested page without filters or automatic follow-up requests.
They do not fetch task details, recordings or analysis for any returned ID. Missing totals/page
counts remain `null` in memory and `unknown` in the command; tags use `n/a` for pagination.

Tag rows require a numeric string or integer `tagCode` and a nonempty string `tagName`. The code,
label and extra fields stay as returned: there is no intent classification or model update.
The account's observed codes were strings: 1 high, 9 medium, 10 low, 2 no intent, plus 7 whose label
was not retained by the probe's redaction whitelist. Unknown numeric codes remain vendor facts;
no code is silently mapped into high/medium/low.

HTTP 2xx plus integer/string `code=10000` is required. Optional `success` must be boolean true.
Malformed JSON, unknown envelopes/pages, wrong-tenant rows and contradictory identity fail explicitly.
Empty successful pages remain distinct from errors. `code=-10000` yields `session_expired` and stops.
Other safe reasons include `disabled`, `not_configured`, `auth_failed`, `identity_not_found`,
`ambiguous_identity`, `identity_mismatch`, `device_restricted`, `untrusted_origin`, `http_error`,
`transport_error`, `query_failed` and protocol-shape failures. Exceptions contain no vendor text or
retained HTTP exception. Password parameters are sensitive; neither passwords nor tokens are logged.
The existing Inspector transport strips request/response details on the two fixed App hosts, keeping
only method, URL and status. Other providers retain their existing monitoring behavior.

The client returns validated page rows or recording details **in memory only**; no token is returned or held on an object,
in cache, Redis, files, database or jobs. Explicit row `companyCode` must match the selected tenant.
The command shows resource/status/counts and types/presence for fixed field names, never raw rows,
IDs, names, phones, recordings, transcripts or credentials. There is no raw-output option.

### Limits still requiring evidence

- History `id`, task/subtask IDs, local `actionId` and API `callId` are not interchangeable.
  In the observed local insert path, `CallRecordDbBean.callId` actually holds the subtask ID,
  while recording queries use its `actionId`. App uploads link `taskSubId` and `callActionId`, but
  the result lists were empty before S2. S2 supplies a real task/result chain above;
  history alone still supplies no child/task association.
  No provider ID is invented and no record is passed into a call mapper. **All rows stay read-only,
  including rows carrying a callActionId or high-intent tag; none are automatically matched or written back.**
- `aiAsr` and `aiCall` are integer flags, not transcripts or summaries. Task details/subtasks still
  have **no calling entry point here**; the explicit recording getter is described below.
  Static ordinary-AI callbacks use channel 0 for AI and 1 for the customer; transcript offsets on
  that path use App receipt times relative to connection in milliseconds. This is not verified
  ASR alignment or proof every provider returns that format. A separately authorized 129-second C1
  recording-detail response has been verified; that manual sample has no task association.
  S2 supplies one additional explicitly linked scheduled-task sample, not complete status coverage.
  Terminal status meaning, task/subtask correlation, long-term token renewal, concurrent phone
  sessions and device requirements for future dialling remain unverified. The analysis endpoint
  `analyzeCallRecordV4` starts analysis and is never used as a query.
- Existing-account read access does not establish pricing, official API entitlement or permanent
  exemption from any API service fee. No paid feature is opened by this client.

### Explicit recording metadata and transcript (2026-10-25)

`YunkeAppReadClient::getRecordingByCallId($knownCallActionId)` reuses the same default-off
configuration, verified company/user selection, login, fixed origin, TLS, timeout, no-redirect
and no-retry transport. Its one business request is:

```text
POST https://phone3.yunkecn.com/phone-ai-call/app/voiceFile/getRecordingByCallId
JSON {"callId":"<independently known per-call ID>"}
```

Empty, padded or control/space-containing IDs fail before authentication. No ID is derived
from a phone, time, task/subtask, URL or arbitrary history row. The response must echo the
requested callId byte-exactly. Explicit companyCode/userId fields, when present, must match
the authenticated identity. The shared HTTP/business error checks run first: an HTTP 200 with
code=-10000 is session_expired, not an empty transcript. Mismatches and malformed responses
raise safe reasons with no vendor payload or previous exception retained.

Return fields stay in memory:

| Field | Meaning |
| --- | --- |
| call_id | Exact echoed per-call ID, not a petaV3 row ID |
| recording_url | String metadata only; never navigated to, downloaded or validated for future fetching |
| duration_ms | The observed integer recordingDuration, in milliseconds on this verified path |
| recording_content | The original JSON-encoded transcript string |
| dialogue | Decoded channelId/text/beginTime/endTime facts; channel IDs stay raw, with no CRM turns or inferred speaker roles |
| timing_issues | end_exceeds_duration when a transcript endpoint exceeds the duration; values remain untrimmed |

The parser requires an object response, integer nonnegative duration, string URL/content,
a JSON-array transcript, integer channel/timestamps and string text. Negative/reversed offsets
or mistyped rows are explicit failures. The valid string `[]` is an empty dialogue; a null
response, invalid JSON or `{}` is not silently converted into one. There is no summary/intent
classification, binding lookup, settlement, follow-up or automatic writeback.

The fixture is derived from C1 with replaced ID, URL and all speech text, not an original wire
response. It retains 19 segments, duration 129553 and final endTime 136070 to cover the observed
6517ms overrun without clipping. It is marked DO_NOT_REQUEST and used only through Http::fake
with preventStrayRequests. Implementation tests made no live login/query; the separately
authorized enterprise reads above used the real client and downloaded no audio.

The separately authorized [owner-call recovery](/docs/modules_handbook/shared/voice-agent/yunke-owner-acceptance.md)
later saved metadata for an existing manually supplemented call: exact call ID, uploaded
object and 128774 ms now read back successfully. Cloud recordingContent is an empty
string because original turn offsets were unavailable; this is still a protocol-shape
failure for this strict getter, not a valid empty dialogue. Analysis of independently
recovered native text persisted a Web summary and medium-intent tag while aiAnalysis
remained 0. Neither that flag nor recording URL presence alone proves a complete bundle.
No write/recovery endpoint was added to this read client, and no petaV3 hold was cleared.

The current CLI is unchanged and does not expose this getter or any raw transcript output.
The committed runnable example is the recording regression in YunkeAppReadTest.

### Historical phone inspection (2026-10-24)

The connected V2536A runs Android 16/API 36 and App 2.0.20/20020; its APK hash matches the
static evidence above. The user confirms that this phone **did not make the earlier calls**
and its App history page is empty. This does not invalidate the three server history rows.

Room uses private `aiOutbound.db` (schema 31). ADB access was denied and run-as rejected the
non-debuggable package, so no database rows were read or counted. Accessible audio caches
were inspected by filename only. Existing logcat plus two external App logs yielded no usable
task/call IDs; the only explicit taskSubId was null. Logs were processed in memory without
persisting their raw contents; audio contents were not read.

At that inspection, the missing input was the actual call-origin phone, its supported export
of existing records, or vendor-provided existing redacted samples. The later C1 sample above
verifies the recording path but still supplies no task association. Local task_id/call_id/action_id retain their
own meanings; a local call_id is not automatically a Web callId. This check changed no App data/settings and made no Yunke API query; it enables no caller.

## Reference usage

The sole consumer is [ReadYunkeApp](/app/Console/Commands/ReadYunkeApp.php):

```text
php artisan voice-agent:yunke-app-read tasks
php artisan voice-agent:yunke-app-read history --page=1 --page-size=1
php artisan voice-agent:yunke-app-read results --page=1 --page-size=1
php artisan voice-agent:yunke-app-read interested --page=1 --page-size=1
php artisan voice-agent:yunke-app-read tags
```

These commands currently fail with `disabled` and send nothing. No credentials are accepted as CLI
arguments. Keep **YUNKE_APP_READ_ENABLED=false** in actual environments; this baseline registers no Yunke caller.
Blank examples are in `.env.example`; do not paste a real password into shell history or test data.
The authorized live probes above used temporary in-memory configuration, never these production
commands or persistent environment changes. Further live reads require their own authorization.

[YunkeAppReadTest](/tests/Feature/VoiceAgent/YunkeAppReadTest.php) is the runnable synthetic example:
it enables only in-memory configuration and uses `Http::fake()` / `preventStrayRequests()` for
every request. The normal command performs exactly three requests; an auth failure stops earlier.

## Related files

- [YunkeAppReadClient](/src/Common/VoiceAgent/YunkeApp/YunkeAppReadClient.php) — fixed auth/query paths and strict identity/page validation.
- [YunkeAppPassword](/src/Common/VoiceAgent/YunkeApp/YunkeAppPassword.php) — APK password transform and a fixed independent test vector.
- [YunkeAppReadException](/src/Common/VoiceAgent/YunkeApp/YunkeAppReadException.php) — safe reason without vendor payloads.
- [ReadYunkeApp](/app/Console/Commands/ReadYunkeApp.php) — bounded redacted console consumer, auto-discovered by the Console Kernel.
- [config/services.php](/config/services.php), [.env.example](/.env.example), [phpunit.xml](/phpunit.xml) — independent default-off read configuration and test isolation.
- [RedactingInspectorTransport](/app/Support/Monitoring/RedactingInspectorTransport.php) and [FcmInspectorRedactionTest](/tests/Unit/AgentApp/FcmInspectorRedactionTest.php) — targeted APM redaction.
- [YunkeAppReadTest](/tests/Feature/VoiceAgent/YunkeAppReadTest.php) — fake-only protocol, console, explicit recording details and no-side-effect tests (no database reset).
- [Redacted C1 fixture](/tests/Fixtures/VoiceAgent/yunke-app-recording-redacted.json) — replaced identifiers/URL/text, with observed transcript shape and timing edge case.

No frontend, migrations, routes, seeders or schedules.
